When nginx configuration only uses ip or domain name to visit, it will point to the same page

Suppose the server ip 12.34.12.12; you want to configure to redirect access to the /dir/null.html file when accessing http://12.34.12.12, the configuration is as follows (the same applies to access only with domain names, but the localhost at server_name is changed to yours domain name)

  server {
        listen       80;
        server_name  localhost;
        root /home/wwwroot/;

        location / {            root /home/wwwroot/;            index index.html;            rewrite ^/$ /dir/null.html break; //This sentence is the key, redirect to the /dir/null.html page         }



}

Guess you like

Origin blog.csdn.net/weixin_37281289/article/details/103473394