nginx的Rewrite重写

    location /{
               if ($remote_addr=192.168.1.100){                          //禁止此 ip 访问
                    return 403;
               }
               root /usr/local/html;
               index index.html index.htm;
    }
 
    location /{
               if ($http_user_agent ~ MSIE){                          //如果使用的是 ie 浏览器【 access.log 里有浏览器的头信息】
                    rewrite ^.*$ /ie.html                                    //无论访问那个页面 都让他重写到根目录下 的 ie.html
                    break;                                                          //不加 break 会一直匹配到这里形成死循环。
               }
               root /usr/local/html;
               index index.html index.htm;
    }
 
    location /{
               if (!-e $document_root$fastcgi_script_name){                               //如果访问页面不存在
                    rewrite ^.*$ /404.htm;                                                            //将被重定向到  404 页面
                    break;
               }
               root /usr/local/html;
               index index.html index.htm;
    }
 
    location /{
               if ($http_user_agent ~* msie){                                   //如果访问者使用的 ie 浏览器
                    set $isie 1;
               }
               if ($fastcgi_script_name=ie.html){                              //如果访问的是 ie.html
                    set $isie 0;
               }
               if ($isie 1){                                                                 //如果是 ie 浏览器且不是访问的 ie.html,重写到 ie.html
                    rewrite ^.*$ ie.html;
               }
               root /usr/local/html;
               index index.html index.htm;
    }






  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值