Question
How can I do 301 Redirect in nginx for 200 URLs?
I have 200 URLs that I need to redirect to new URLs
e.g.
http://abc.com/one/p-SF10 —–> http://abc.com/one/p-SF134
http://abc.com/one/p-SM28 —–> http://abc.com/one/p-SM28
http://abc.com/one/p-KH83 —–> http://abc.com/one/p-KH194
On Apache it was very simple to do in .htaccess like:
Redirect 301 /one/p-SF10 http://www.abc.com/one/p-SF134
Redirect 301 /one/p-SM28 http://www.abc.com/one/p-SM28
Redirect 301 /onep-KH83 http://www.abc.com/one/p-KH194
I found one of the guides with following lines:
if ( $request_filename ~ oldpage/ ) {
rewrite ^ http://www.domain.com/newpage/? permanent;
}
My question here is do I need to create these 200 ’if conditions’? Wouldn’t it create a huge conditional loop and overload my server?
Server configuration:
I installed Nginx+php-fpm using VestCP and set the nginx template to wordpress from within VestCP which configured my nginx.conf automatically.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×