1

I need to convertthe following Apache htaccess rules to Nginx Rewrite rules:

Redirect 301 /feed.php http://www.example.com/feed/

Thanks very much~

2 Answers 2

3

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.