Home 301 Redirect Specific Pages in Nginx BEFORE Redirecting Entire Domain/Catch All
Reply: 0

301 Redirect Specific Pages in Nginx BEFORE Redirecting Entire Domain/Catch All

user1086
1#
user1086 Published in May 23, 2018, 4:47 pm

I have thousands of pages to 301 redirect in nginx. I can achieve this using

return 301 https://www.newdomain.com$request_uri;

However, there is approximately 6 pages that I would like to redirect to a changed slug/path on the new domain, eg

   location /old-path/ {
   rewrite ^ https://www.newdomain.com/newpath/ permanent;
   }

I have tried but can't see to work out how to redirect these 6 first, specifically, and then have the catch all rule apply to everything else.

At the moment I am redirecting on the old domain using the catch all only, and then have 301s on the new domain changing the 6 posts to the new paths (2 redirects total for these 6 posts).

I would like to achieve the above not only to reduce the redirects to 1 for these 6 pages, but also because I want to redirect one of the 6 pages to a new path on the new domain, but it's old path still exists as a (new) page on the new domain too (therefore I need to redirect it on the old domain, not on the new one).

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.35609 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO