Welcome! Log In Create A New Profile

Advanced

Re: Redirect question

March 23, 2018 11:24AM
Ok, that worked out really well.

For anyone following I had to go here
https://forum.nginx.org/read.php?2,279172,279176#msg-279176
because our exchange server destroyed the sample URLs.

But I’m not sure how the location order is mitigated. Is this because the first location match is a regex instead of just a string match?

___________________________________________
Michael Friscia
Office of Communications
Yale School of Medicine
(203) 737-7932 - office
(203) 931-5381 - mobile
http://web.yale.edu http://web.yale.edu/


On 3/23/18, 11:04 AM, "nginx on behalf of Igor Sysoev" <nginx-bounces@nginx.org on behalf of igor@sysoev.ru> wrote:



> On 23 Mar 2018, at 16:14, Friscia, Michael <michael.friscia@yale.edu> wrote:
>
> I’m wondering how to achieve this in the config
>
> I have a url like this
> https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_people_mike&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=d-eqNL5YgMJ1AKeHKJOtXnHHNtzi9Z1jTzjuytLCfu8&e=
>
> and I want to redirect to
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.othersite.com_users_mike&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=s3EYsk58VjmTeyiIyIvDdkIV6OWmBL9HsdDGIWnT7oA&e=
>
> the problem at hand is switching “/people/” to “/users/” but keep everything else so if I was to have
> https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_people_mike_education-3Fpage-3D1&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=Jg2LCkkCd0MtLQdRgKJn_Qw3KVPphD5g1M6YGmxLYMI&e=
> I would still get redirected to
> https://urldefense.proofpoint.com/v2/url?u=https-3A__www.othersite.com_users_mike_education-3Fpage-3D1&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=6b4ktk2Q5Fa3Ro1Hg2qGdD9dhsIk5Ap-3cS_GbOSBc0&e=
>
> I currently have redirects where I just append $request_uri to the new domain name but in this case I need to alter the $request_uri before I use it. So the question is how should I approach making this sort of change?

Something like this:

location ~ ^/people/(?<REST>.+) {
return 301 https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_users_-24REST-24is-5Fargs-24args&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=dwsx2pgviho1mDEe9-eSJOsU6L5YomDKne9pGahGEII&e=;
}

However, if you do not want to care about location order in future, this is better:

location /people/ {
location ~ ^/people/(?<REST>.+) {
return 301 https://urldefense.proofpoint.com/v2/url?u=http-3A__example.com_users_-24REST-24is-5Fargs-24args&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=dwsx2pgviho1mDEe9-eSJOsU6L5YomDKne9pGahGEII&e=;
}
}


--
Igor Sysoev
https://urldefense.proofpoint.com/v2/url?u=http-3A__nginx.com&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=G8eSWJNBD_3_Eg6m9BGtziqdxy0G0D38NiN75tlpYHU&e=

_______________________________________________
nginx mailing list
nginx@nginx.org
https://urldefense.proofpoint.com/v2/url?u=http-3A__mailman.nginx.org_mailman_listinfo_nginx&d=DwIGaQ&c=cjytLXgP8ixuoHflwc-poQ&r=wvXEDjvtDPcv7AlldT5UvDx32KXBEM6um_lS023SJrs&m=3O_LBJK37dgtTRVYwIUXbeYZOEoMAFuwQka4abHmvc0&s=8dvq4qhKfz_X0MxXZ6Qaeik8x47SP3epk7aqPxYGoh4&e=

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

Redirect question

wickedhangover March 23, 2018 09:16AM

Re: Redirect question

Igor Sysoev March 23, 2018 11:06AM

Re: Redirect question

wickedhangover March 23, 2018 11:24AM

Re: Redirect question

Igor Sysoev March 23, 2018 11:40AM

Re: Redirect question

wickedhangover March 23, 2018 11:40AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 192
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready