一个域名能实现 pc 访问 index.html,手机访问 index.php 吗?

2016-05-28 17:13:05 +08:00
 xingshu
请教各位,一个域名能实现 pc 访问 index.html ,手机访问 index.php 吗?
5206 次点击
所在节点    NGINX
17 条回复
ca1123
2016-05-28 17:20:12 +08:00
你这个只能在 Web 服务器上实现, DNS 做不到。
如果在 web 服务器上,当然是可以的
你根据 UA 跳转似乎就可以了吧
具体的得 我也是三脚猫
jhdxr
2016-05-28 17:27:35 +08:00
可以,根据 UA 判断下
hao123yinlong
2016-05-28 17:44:16 +08:00
http://detectmobilebrowsers.com/ 常见 WebServer 都有,判断自己完善下
McContax
2016-05-28 17:50:10 +08:00
我记得 cloudflare 的有个付费功能可以,或者在服务器写个 html .php 判断也行
Smirnoff
2016-05-28 17:52:23 +08:00
可以

----首页判断 是否是 手机 是手机 就跳转到 手机页面
<script type="text/javascript">
var mobileUrl="http://www.xxx.com/index.php",
mobile = (/mmp|symbian|smartphone|midp|wap|phone|xoom|iphone|ipad|ipod|android|blackberry|mini|windows\sce|palm/i.test(navigator.userAgent.toLowerCase()));
if (mobile) {
window.location = mobileUrl;
}
</script>
tadtung
2016-05-28 19:18:14 +08:00
可以,很简单的。 ua 判定就行。
lslqtz
2016-05-28 20:03:27 +08:00
htaccess 判断 ua 重写?
dphdjy
2016-05-28 20:27:57 +08:00
@ca1123 DNS 并不负责 file name 的解析,只处理 hostname
aprikyblue
2016-05-28 20:47:23 +08:00
判断下 ua ,跳转
yexiaoxing
2016-05-28 21:17:52 +08:00
nginx 可以判断 UA
bdbai
2016-05-28 21:26:34 +08:00
既然都能跳转了为什么不直接重写过去呢
asp
2016-05-28 23:12:44 +08:00
index.php 设置成首页,在里面判断客户端特征,电脑用户 301 跳转到 index.html 即可。
Roycom
2016-05-28 23:29:46 +08:00
简单
xiqingongzi
2016-05-29 06:19:50 +08:00
百度有个 js 叫 UaDirect ,巨好用!推荐!在 html 里加载就行
ysoserious
2016-05-29 09:52:18 +08:00
@jhdxr 江湖大虾仁?好熟悉的头像,以前玩 Discuz ?
jhdxr
2016-05-29 17:31:48 +08:00
@borlee2567 嗯。。。你是哪位。。。
ysoserious
2016-05-29 20:22:01 +08:00
@jhdxr 以前修改过宠物游戏的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/281888

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX