I want to redirect a full url using nginx. This doesn't work:
server {
listen 80;
server_name www.domain1.com www.domain2.com www.domain3.com ;
if ($http_host$request_uri ~ www.domain2.com/hello.html) {
rewrite ^ google.com permanent;
}
}
What is the correct way to do this?
I doubt whether the variable $http_host$request_uri can match to that address.
Apparently
if
cannot deal with expressions very well. I'd rewrite your configuration like this:It might be too late for you but It resolved my problem and I hope it helps someone...