nginx首页根据IP跳转-日常笔记

来源:互联网 发布:数组怎么表示 编辑:程序博客网 时间:2024/05/09 19:21

   公司要根据ip跳转到不同网站子平台(仅限首页),于是尝试了下,最终写了两个location,不知道有没有什么简单的写法

location = / {

         if ($remote_addr = 192.168.1.1) {
                  rewrite ^(.*)$ http://www.baidu.com/index.html break;
         }
 }

   

location = /index.html {

         if ($remote_addr = 192.168.1.1) {
                  rewrite ^(.*)$ http://www.baidu.com/index.html break;
         }
 }
0 0
原创粉丝点击