如何不让网页跳转移动端

如何不让网页跳转移动端,第1张

场景,示例域名描述

Pc:www.wendabaike.com(供PC访问官方网站)

移动:m.wendabaike.com(用于移动接入)

现在的需求是这样的:

在个人电脑方面,www.wendabaike.com和m.wendabaike.com的访问量跃升至www.wendabaike.com。

在手机上,www.wendabaike.com和m.wendabaike.com的访问跳转到了m.wendabaike.com。

Pc端配置:www.wendabaike.com

服务器{

听80;

服务器名www.wendabaike.com;

# charset koi 8-r;

# access _ log logs/host . access . log main;

#以下可根据user_agent获得

if ($http_host!~ quot^www.wendabaike.com$quot;) {

重写^(.*) http://www.wendabaike.com永久;

}

if ($http_user_agent ~*(手机|诺基亚| iphone | ipad |安卓|三星| htc |黑莓)){

重写^(.*)http://m . wenda bake . com $ 1永久;

}

位置/ {

root/home/build/rash-home-front/dist/html;

索引index.html index.htm;

}

}

部分代码如下:

if ($http_host!~ quot^www.wendabaike.com$quot;) {

重写^(.*) http://www.wendabaike.com永久;

}

if ($http_user_agent ~*(手机|诺基亚| iphone | ipad |安卓|三星| htc |黑莓)){

重写^(.*)http://m . wenda bake . com $ 1永久;

}

移动配置:m.wendabaike.com

服务器{

听80;

服务器名m.wendabaike.com;

# charset koi 8-r;

# access _ log logs/host . access . log main;

#非移动终端跳转到www.wendabaike.com

if ($http_user_agent!~*(手机|诺基亚| iphone | ipad | android |三星| htc |黑莓)){

重写^(.*) http://www.wendabaike.com永久;

}

位置/ {

root/home/build/rash-mobile-front/dist;

索引index.html index.htm;

}

}

部分代码如下:

if ($http_user_agent!~*(手机|诺基亚| iphone | ipad | android |三星| htc |黑莓)){

重写^(.*) http://www.wendabaike.com永久;

}

至此,相关配置已经完成。

作者:阿良低语

欢迎分享,转载请注明来源:聚客百科

原文地址: http://juke.outofmemory.cn/life/627313.html

()
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-07-07
下一篇 2022-07-07

发表评论

登录后才能评论

评论列表(0条)

保存