March 23, 2018 11:06AM
> 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
> http://example.com/people/mike
>
> and I want to redirect to
> https://www.othersite.com/users/mike
>
> the problem at hand is switching “/people/” to “/users/” but keep everything else so if I was to have
> http://example.com/people/mike/education?page=1
> I would still get redirected to
> https://www.othersite.com/users/mike/education?page=1
>
> 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 http://example.com/users/$REST$is_args$args;
}

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

location /people/ {
location ~ ^/people/(?<REST>.+) {
return 301 http://example.com/users/$REST$is_args$args;
}
}


--
Igor Sysoev
http://nginx.com

_______________________________________________
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: 181
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready