欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

nginx 手机访问电脑站 跳转到 手机站 自己亲自做的 有大用 有大大用 有大大大用

见下面几处所有红色的

匹配条件 若使用 (android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos)

配置时会出现 Stopping nginx: nginx: [emerg] invalid condition "$http_user_agent" in /www/wdlinux/nginx-1.8.1/conf/vhost/aaaa.cn.conf:6

切记 看下面的红色的匹配 (注意不要用括号把所有匹配括起来   )

server {  # 80端口的配置

        listen       80;

        root /home/wwwroot/aaaa_cn/public_html;

        server_name shrszg.cn www.aaaa.cn 

        index  index.html index.php index.htm;

        if ($http_user_agent ~* "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos|xiaoMi\/MiuiBrowser"){

           rewrite ^.*$  http://wap.aaaa.cn permanent;

         }

        error_page  400 /errpage/400.html;

        error_page  403 /errpage/403.html;

        error_page  404 /errpage/404.html;

        error_page  503 /errpage/503.html;

}


server {    #443端口的配置

        listen       443;

        root /home/wwwroot/aaaa_cn/public_html;

        ssl                  on;

        ssl_certificate      cert/shrszg.cn.pem;

        ssl_certificate_key  cert/shrszg.cn.key;

        ssl_prefer_server_ciphers on;

        ssl_session_timeout 10m;

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

        ssl_ciphers EECDH+CHACHA20:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;

        server_name shrszg.cn www.shrszg.cn;

        index  index.html index.php index.htm;

        if ($http_user_agent ~* "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera mobile|palmos|webos|xiaoMi\/MiuiBrowser"){

           rewrite ^.*$  https://wap.aaaa.cn permanent;

         }

        error_page  400 /errpage/400.html;

        error_page  403 /errpage/403.html;

        error_page  404 /errpage/404.html;

        error_page  503 /errpage/503.html;


普通分类: