Need help converting Apache2 Rewrite rules to nginx Need help converting Apache2 Rewrite rules to nginx nginx nginx

Need help converting Apache2 Rewrite rules to nginx


This:

RewriteRule ^(.+)/$ http://%{HTTP_HOST}/$1 [R=301,QSA,L]

will be converted to:

rewrite ^/(.+)/$ http://$http_host/$1 permanent;

and this:

RewriteRule !^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ index.php

will be converted to:

rewrite /!^(media/(.+)|favicon.ico|robots.txt|sitemap.xml|sitemap-main.xml)$ /index.php;

you can also use:

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;}

Documentation: http://wiki.nginx.org/HttpRewriteModule

From: http://www.anilcetin.com/convert-apache-htaccess-to-nginx/