301 redirect

JACK LINKERS jacklinkers at gmail.com
Sat Feb 14 22:30:19 UTC 2015


Hi Francis,

Thanks for your input. What would be the best ways doing it then ?
(I forgot to mention there is a large amount of URLs : +/- 20)

Is this a good way ? :

map $old $new {
  oldlink.html newlink.com
  oldink2.html newlink2.html
}

location $old {
  return 301 $scheme://$host$new;
}

If not, could you show me an example ?

Thanks in advance


2015-02-14 23:22 GMT+01:00 Francis Daly <francis at daoine.org>:

> 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
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20150214/2a10caa1/attachment-0001.html>


More information about the nginx mailing list