Nginx常用Rewrite偽靜態法則

2022-08-16 12:54:12 字數 2538 閱讀 3788

信賴此刻大部門用linux vps的伴侶都在利用這個敏捷傳布的nginx,本日就清算一下最常見的php法式的rewrite(偽靜態法則)。

wordpress:

location /

if (-f $request_filename/index.php)

if (!-f $request_filename)

}phpcms:

location /

ecshop:

if (!-e $request_filename)

shopex:

location /

}sablog 2.0:

# 只帶月份的歸檔

rewrite "^/date/([0-9])/?([0-9]+)?/?$" /index.php?action=article&setdate=$1&page=$2 last;

# 無分類翻頁

rewrite ^/page/([0-9]+)?/?$ /index.php?action=article&page=$1 last;

# 分類

rewrite ^/category/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&cid=$1&page=$2 last;

rewrite ^/category/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&curl=$1&page=$2 last;

# 歸檔、高階搜刮

rewrite ^/(archives|search|article|links)/?$ /index.php?action=$1 last;

# 全數批評、標籤列表、引用列表 帶分頁

rewrite ^/(comments|tagslist|trackbacks|article)/?([0-9]+)?/?$ /index.php?action=$1&page=$2 last;

# tags

rewrite ^/tag/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&item=$1&page=$2 last;

# 文章

rewrite ^/archives/([0-9]+)/?([0-9]+)?/?$ /index.php?action=show&id=$1&page=$2 last;

# rss rewrite ^/rss/([0-9]+)?/?$ /rss.php?cid=$1 last;

rewrite ^/rss/([^/]+)/?$ /rss.php?url=$1 last;

# 使用者 rewrite ^/uid/([0-9]+)/?([0-9]+)?/?$ /index.php?action=article&uid=$1&page=$2 last;

rewrite ^/user/([^/]+)/?([0-9]+)?/?$ /index.php?action=article&user=$1&page=$2 last;

# 輿**件

rewrite sitemap.xml sitemap.php last;

# 自界說鏈結

rewrite ^(.*)/([0-9a-za-z\-\_]+)/?([0-9]+)?/?$ $1/index.php?action=show&alias=$2&page=$3 last;

discuz 7:

rewrite ^/archiver/((fid|tid)-[\w\-]+\.html)$ /archiver/index.php?$1 last;

rewrite ^/forum-([0-9]+)-([0-9]+)\.html$ /forumdisplay.php?fid=$1&page=$2 last;

rewrite ^/thread-([0-9]+)-([0-9]+)-([0-9]+)\.html$ /viewthread.php?tid=$1&extra=page\%3d$3&page=$2 last;

rewrite ^/space-(username|uid)-(.+)\.html$ /space.php?$1=$2 last;

rewrite ^/tag-(.+)\.html$ /tag.php?name=$1 last;

typecho:

location /

if (-f $request_filename/index.php)

if (!-f $request_filename)

}4.8.5 shopex  啟用偽靜態

location /

if (!-e $request_filename) {

rewrite ^/(.*)$ /index.php?$1 last;

1.      啟用偽靜態

##begin add by guozhenbin 20100727 (use pseudo-static)

location /

if (!-e $request_filename) {

rewrite ^/(.*)$ /index.php?$1 last;

##end add by guozhenbin 20100727

Nginx常用Rewrite偽靜態法則

信賴此刻大部門用linux vps的伴侶都在利用這個敏捷傳布的nginx,本日就清算一下最常見的php法式的rewrite 偽靜態法則 wordpress location if f request filename index.php if f request filename phpcms lo...

Nginx常用Rewrite偽靜態法則

信賴此刻大部門用linux vps的伴侶都在利用這個敏捷傳布的nginx,本日就清算一下最常見的php法式的rewrite 偽靜態法則 wordpress location if f request filename index.php if f request filename phpcms lo...

apache配置偽靜態Rewrite

找到這一行 loadmodule rewrite module modules mod rewrite.so 改成loadmodule rewrite module modules mod rewrite.so 儲存httpd.conf 找到標記,標記之間有 allowoverride none 修...