nginx redirects when accessing a specific page
迷茫
迷茫 2017-05-16 17:10:55
0
1
457

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?

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all (1)
过去多啦不再A梦

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

server { listen 80; server_name www.domain2.com ; if (request_uri ~* hello.html) { rewrite ^ google.com permanent; } } server { listen 80; server_name www.domain1.com www.domain3.com ; }
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!