nginx伪静态备份

WP博客伪静态,万能伪静态:
[code]
rewrite ^.*/files/(.*)$ /wp-includes/ms-files.php?file=$1 last;

if (!-e $request_filename) {

rewrite ^.+?(/wp-.*) $1 last;

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

rewrite ^ /index.php last;

}
[/code]

电商网站的自定义伪静态
[code]
rewrite ^/index_(hot|new)(_(\d+))?.html$ /index.php?ac=index&st=$1&page=$3 last;
rewrite ^/index_(\d+).html$ /index.php?ac=index&page=$1 last;
rewrite ^/([a-zA-Z]+)_(new|hot)(_(\d+))?.html$ /index.php?ac=$1&st=$2&tid=$4 last;
rewrite ^/([a-zA-Z]+)_(new|hot)_(\d+)_(\d+).html$ /index.php?ac=$1&st=$2&tid=$3&page=$4 last;
rewrite ^/([a-zA-Z]+)_(\d+)_(\d+).html$ /index.php?ac=$1&tid=$2&page=$3 last;
rewrite ^/([a-zA-Z]+)(_(\d+))?.html$ /index.php?ac=$1&tid=$3 last;
[/code]

齐博cms 580gk.cn 伪静态
[code]
location /{
#rewrite ^/bencandy-city_id-(\d+)-fid-(\d+)-id-(\d+).html$ /bencandy.php?city_id=$1&fid=$2&id=$3 last;
#rewrite ^/list-city_id-(\d+)-fid-(\d+).html$ /list.php?city_id=$1&fid=$2 last;
#rewrite ^/list-city_id-(\d+)-fid-(\d+)-sortid-(\d+).html$ /list.php?city_id=$1&fid=$2&sortid=$3 last;
rewrite ^(.*)/(list|bencandy)-([^\.]+)\.([a-zA-Z0-9]+)$ $1/$2.php?stringID=$3 last;
}
[/code]

此文用作记录,还为以后写ng伪静态做参考。

以下是apache htaccess 赚nginx rewrite规则

[code]
Options -Indexes
RewriteEngine on
RewriteCond %{QUERY_STRING} ^(.*)$
RewriteRule ^(?!rewrite.php)(.*)$ /rewrite.php?rewrite=$1&%1 [L]
[/code]

转换后:

[code]
if ($args ~ "^(.*)$"){
set $rule_0 1$rule_0;
set $bref_1 $1;
}
if ($rule_0 = "1"){
rewrite ^/(?!rewrite.php)(.*)$ /rewrite.php?rewrite=$1&$bref_1 last;
}

[/code]

转换网址:http://www.anilcetin.com/convert-apache-htaccess-to-nginx/