Welcome! Log In Create A New Profile

Advanced

location redirect always with trailing slash... sometimes

March 07, 2019 08:58AM
Hi

I have this buggy backend application where I try to let Nginx sort out the
problems.

Example of required redirect:
http://ex.org/foo -> https://ex2.org/foo/ # Nx solves the bug here
http://ex.org/foo/ -> https://ex2.org/foo/
http://ex.org/foo/?id=7 -> https://ex2.org/?id=7

Here is my current configuration which is in too parts but I have the idea
that I'm doing it wrong and it can be done in only one "location" with a
regex:

location ~ /foo$ {
return 301 https://ex2.org$request_uri/;
}
location ~ /foo/$ {
return 301 https://ex2.org$request_uri;
}

I have several paths like /foo/ where I would like to have them all in one
regex like
location ~ /(foo|bar)/$ {

--

Venlig hilsen - best regards
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

location redirect always with trailing slash... sometimes

hsc@miracle.dk March 07, 2019 08:58AM

Re: location redirect always with trailing slash... sometimes

hsc@miracle.dk March 08, 2019 04:00AM

Re: location redirect always with trailing slash... sometimes

Francis Daly March 11, 2019 05:04AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 95
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready