Reputation: 325
I have www.example.com and booking.example.com and I want to redirect booking.example.com/partners to example.com/partners.
I'm currently using
location ~ ^/partners/(.*) {
return 301 http://www.example.com/partners/$1;
}
but now I want to redirect an old defunct link to a new one, for example, booking.example.com/partners/doesntexist to www.example.com/partners/doesexist
I tried to do this:
location "^/partners/IDoNotExistAnymore" {
return 301 http://www.example.com/partners/CorrectLink;
}
But it doesn't work, it always redirects to route.
Upvotes: 0
Views: 22
Reputation: 49812
You need to check the syntax of the location
directive. See this document for details.
You seem to be using regular expression locations, but prefix locations and exact match locations will be more efficient in this case:
location ^~ /partners {
return 301 http://www.example.com$request_uri;
}
location = /partners/IDoNotExistAnymore {
return 301 http://www.example.com/partners/CorrectLink;
}
Upvotes: 1