301 redirect

Francis Daly francis at daoine.org
Sat Feb 14 22:22:20 UTC 2015


On Sat, Feb 14, 2015 at 10:57:26PM +0100, JACK LINKERS wrote:

> But how do I redirect URLs that have been changed ?
> ie. https://mywebsite.com/oldname.html to https://mywebsite.com/newname.html

location = /oldname.html { return 301 /newname.html; }

> I did try
> 
>    if ( $request_filename ~ oldname.html/ ) {
>       rewrite ^ https://mywebsite.com/newname.html/? permanent;
>    }
> 
> But this doesn't work.

Yes, it does. If your incoming request matches the string "oldname.html/".

It just isn't a very good way of implementing it.

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list