当用手机访问网站时自动跳转到手机端站点,当用电脑访问网站时自动跳转到PC端站点
PC端nginx配置文件中加入如下代码:
#移动端访问跳转到m.q0738.com
if ($http_user_agent ~* (android|iphone|phone|pad|pod|ipod|ios|ipad|mobile|blackberry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|WindowsPhone)) {
rewrite ^$ http://m.q0738.com/ permanent;
rewrite ^(.*)/$ http://m.q0738.com$1/ permanent;
rewrite ^(.*).html$ http://m.q0738.com$1.html permanent;
}
移动端nginx配置文件中加入如下代码:
#PC端访问跳转到www.q0738.com
if ($http_user_agent !~* (android|iphone|phone|pad|pod|ipod|ios|ipad|mobile|blackberry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|WindowsPhone)) {
rewrite ^$ http://www.q0738.com/ permanent;
rewrite ^(.*)/$ http://www.q0738.com$1/ permanent;
rewrite ^(.*).html$ http://www.q0738.com$1.html permanent;
}