I'm sure this has been asked before, but I can't find a solution that works.
A website has switched CMS services, but has the same domain, how do I set up an nginx rewrite for a single page?
E.g.
Old Page
http://sitedomain.co.uk/content/unique-page-name
New page
http://sitedomain.co.uk/new-name/unique-page-name
Please note, I don't want everything within the content page to be redirected, but literally just the url mentioned above. I have about 9 redirects to set up, non of which fit in a pattern.
Thanks!
Edit: I found this solution, which seems to be working, except for the fact that it redirects without a slash:
if ( $request_filename ~ content/unique-page-name/ ) {
rewrite ^ http://sitedomain.co.uk/new-name/unique-page-name/? permanent;
}
But this redirects to:
http://sitedomain.co.uknew-name/unique-page-name/
ifstatements in nginx is bad? Would this still be better practice than using the rewrite method? – SteveEdson Oct 25 '13 at 10:10ifalong with return directive is perfectly fine. See http://wiki.nginx.org/IfIsEvil . Yes, IMO, it's better than using rewrite. – Pothi Kalimuthu Oct 25 '13 at 10:22return ...instead ofrewrite ... ... permanent;for the permanent redirects? Is there a reason why that that should be preferred? In that current answer there's no longer aifstatement, was that why? – luckydonald Aug 05 '20 at 11:30