[英]Need help converting Apache2 Rewrite rules to nginx
我设法转换了其中的大多数,但是我在这两个方面有些挣扎-
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,QSA,L]
RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ index.php
如果有人是nginx重写忍者,将不胜感激:)
这个:
RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,QSA,L]
将转换为:
rewrite ^/(.+)/$ http://$http_host/$1 permanent;
和这个:
RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ index.php
将转换为:
rewrite /!^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ /index.php;
您还可以使用:
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;
}
文档: http : //wiki.nginx.org/HttpRewriteModule
来自: http : //www.anilcetin.com/convert-apache-htaccess-to-nginx/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.