Gar*_*ies 5 apache mod-rewrite nginx url-rewriting
我已经设法转换了大部分,但我在这两个方面有点挣扎 -
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,QSA,L]
RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ index.php
Run Code Online (Sandbox Code Playgroud)
如果有人是一个nginx重写忍者会很感激的手:)
这个:
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,QSA,L]
Run Code Online (Sandbox Code Playgroud)
将被转换为:
rewrite ^/(.+)/$ http://$http_host/$1 permanent;
Run Code Online (Sandbox Code Playgroud)
还有这个:
RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ index.php
Run Code Online (Sandbox Code Playgroud)
将被转换为:
rewrite /!^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ /index.php;
Run Code Online (Sandbox Code Playgroud)
你也可以用:
if ($rule_0 = ""){
rewrite ^/(.+)/$ http://$http_host/$1 permanent;
}
if ($rule_0 = ""){
rewrite /!^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ /index.php;
}
Run Code Online (Sandbox Code Playgroud)
文档:http://wiki.nginx.org/HttpRewriteModule
来自:http://www.anilcetin.com/convert-apache-htaccess-to-nginx/