上文講了htaccess轉iis的httpd.ini偽靜態規則
下面再談談如何把apache的htaccess規則轉到nginx下!
簡單舉個例子,如apache下的這樣一條偽靜態規則
RewriteRule ^/([0-9]+)/?$ index.php?s=content/index/loupan&t=zhuye&catid=14&id=$1 [L]轉換到nginx下后為下面這樣,其實改動還是很小的!
RewriteRule ^/index.html?$ index.php?s=content/index/loupan&t=zhuye&catid=14&id=$1 [L]
location / {
rewrite ^/([0-9]+)/?$ /index.php?s=content/index/loupan&t=zhuye&catid=14&id=$1 last;
rewrite ^/index\.html$ /index.php?s=content/index/loupan&t=zhuye&catid=14&id=$1 last;
}
RewriteCond %{QUERY_STRING} keyword=(.*)
RewriteRule ^/list.html(.*) index.php?s=content/index/lists&catid=14&keyword=%1 [L]
if ($query_string ~ ^keyword=(.*)$) {
set $id_tmp $1;
rewrite "^/list.html$" index.php?s=content/index/lists&catid=14&keyword=$id_tmp permanent;
}
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。