通过nginx判断移动端还是pc端,访问不同的目录
帝国cms 的移动端和pc端正常是需要配置不同的域名,但是想实现访问相同的url,通过nginx判断ua,pc用户访问/pc目录,移动用户访问/m目录,按照网上的方法,提交不了或者提交后不生效location / {
set $is_mobile 0;
if ($http_user_agent ~* (mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)) {
set $is_mobile 1;
}
# PC端
if ($is_mobile = 0) {
root /www/wwwroot/pc;
}
# 移动端
if ($is_mobile = 1) {
root /www/wwwroot/m;
}
}请问怎么解决,或者有没有更好的方案
页:
[1]