zoukankan      html  css  js  c++  java
  • nginx 同一个域名下分终端重定向

    不能放到location外(全局),会造成重定向死循环

    放到location内,因为是同一域名会造成部分uri一起重定向造成页面显示不正常。

    加了访问绝对路径 /  

    同时判断user_agent 为手机 才重定向

    第二个location 也是为了死循环
    location / {
      set $a 1;
      set $b 2;

      if ($request_uri ~* "^/$") {
        set $a 0;
      }
      if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
        set $b 0;
      }
       if ($a = $b) {
        rewrite ^/(.*)$ https://aaa.test.duia.com/wap/g-p/employment/$1 permanent;
      }  

      proxy_pass http://aaa.test.duia.com;
    }

    location /wap/g-p/employment {
    proxy_pass http://aaaa.test.duia.com;
    }

    不同域名:

    if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
      rewrite ^/(.*)$ https://bbb.test.duia.com/wap/g-p/employment/$1 permanent;
    }

  • 相关阅读:
    计算几何
    差三角
    约瑟夫
    字符编码
    河南省赛之Substring
    移动字母
    抽屉原理
    不要为了完成代码而写代码
    分布式文件系统优化
    降低代码的复杂度
  • 原文地址:https://www.cnblogs.com/sqbk/p/15211614.html
Copyright © 2011-2022 走看看