Reputation: 11
I need to convertthe following Apache htaccess rules to Nginx Rewrite rules:
Redirect 301 /feed.php http://www.example.com/feed/
Thanks very much~
Upvotes: 1
Views: 2400
Reputation: 113
Use the following bash one-liner, to convert Apache Redirect lines in the .htaccess file:
while read LINE; do echo -e `echo $LINE | egrep '^Redirect' | cut -d' ' -f1-2` "{\n\treturn 301 `echo $LINE|cut -d' ' -f3`;\n}"; done < .htaccess
As a result,
Redirect /feed.php http://www.example.com/feed/
... lines are printed to the following Nginx style:
location /feed.php {
return 301 http://www.example.com/feed/;
}
Upvotes: 1
Reputation: 9294
Formatting's a bit off, but I assume your original rule was
Redirect 301 /feed.php http://www.example.com/feed/
so the Nginx rewrite would be
rewrite ^/feed\.php http://www.example.com/feed/ permanent;
Not difficult if you read the documentation.
Upvotes: 3