There are multiple domain names on an nginx server. If you want to access one of the specific pages, just rewrite to google.com
The configuration is as follows, but it is found that it does not take effect. I feel that $http_host$request_uri does not match that page. .
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; } }
Who knows how to write it?
Write the host that needs to be redirected separately
I just tried it, using $http_host$request_uri ~(.), the matched is an empty string, I don’t know why
If you write it alone, it will be normal
$ http_host ~(.) matches the correct host
$request_uri ~(.) matches the correct uri