Nginx系列:配置跳转的常用方式

基于域名的跳转:

现在公司旧域名http://192.168.2.100有业务需求有变更,需要使用新域名http://http://11.16.11.13/代替。但是旧域名不能废除,需要跳转到新域名上。具体的配置情况如下。

        location / {
    
    
          root /usr/share/nginx/html;
          index index.html;
          
          #当客户浏览器输入http://192.168.2.100就会跳
          #转到http://11.16.11.13
          if ($host = 'http://192.168.2.100/'){
    
    
             rewrite ^/(.*)$ http://11.16.11.13/$1 permanent;
           }
        }

在这里插入图片描述

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_43010385/article/details/113820461