Think before you speak, read before you think.

nginx判断cookie 和 user-agent 跳转到 pc 或 m 站

by

in

如果用户的 cookie 中已经访问过 m 站,或使用手机端的时候,跳转到手机端

        if ($cookie_mobile = "1") {
            rewrite ^ http://m.example.com/ redirect;
        }
        if ($http_user_agent ~* "android|iphone|ipod|windows\sphone") {
            rewrite ^ http://m.example.com/ redirect;
        }

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *