On 14/02/2015 21:57, JACK LINKERS wrote:
Hello,
I need to redirect some URLs after redesigning my website.
I use a 301 redirect for HTTP to HTTPS protocole :
if ($scheme = "http") {
return 301 https://$server_name$request_uri;
}
But how do I redirect URLs that have been changed ?
ie. https://mywebsite.com/oldname.html to
https://mywebsite.com/newname.html
I did try
if ( $request_filename ~ oldname.html/ ) {
rewrite ^ https://mywebsite.com/newname.html/? permanent;
}
But this doesn't work.
My website is hosted on a server with Direct Admin runing on a CentOS
with Nginx as webserver. Don't know if it helps.
Thanks in advance for help
Hi Jack,
I'm no nginx expert, but I think you should use location instead of if,
its faster and less prone to create other errors.
I think you can also use 301 redirects.
I would proceed to set up lots of location clauses thus:
location = /oldurl$ {
return 301 https://$server_name/newurl;
}
Hope this works for you
Ian
--
Ian Hobson
Mid Auchentiber, Auchentiber, Kilwinning, North Ayrshire KA13 7RR
Tel: 0203 287 1392
Preparing eBooks for Kindle and ePub formats to give the best reader experience.
_______________________________________________
nginx mailing list
[email protected]
http://mailman.nginx.org/mailman/listinfo/nginx