PHP移动重定向

发布于 2024-09-24 06:27:25 字数 121 浏览 2 评论 0原文

我已经设法在 php 中开发了一些代码,这些代码将使用移动模板而不是默认模板,但是我不确定是否应该重定向到移动 URL(例如 /mobile/),或者是否可以只使用显示移动模板而不是默认模板。

对此有什么想法吗?

I've managed to develop some code in php which would use a mobile template instead of the default one, however I'm not sure if I should redirect to a mobile URL (such as /mobile/) or if it's ok to just have the mobile template showing up instead of the default.

Any thoughts on this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山色无中 2024-10-01 06:27:25

这取决于你。

某些网站将移动视图放在自己的域中,例如 m.yourdomain.comyourdomain.mobi,如果移动用户访问您的非移动网站 (并通过代理字符串检测到)它们将被重定向到移动域。

然而,蒂姆·伯纳-李 指出

从根本上来说,能够
引用 URI 来获取某些信息
然后在
完全不同的背景。为了
例如,我可能想查找
我的笔记本电脑上的餐厅,将其添加为书签,
然后当我只有手机的时候
检查书签看看
晚上的菜单。或者,我的旅行社
可能会向我发送我的行程指南
出差。我可以查看
从我的办公室出发的大型行程
屏幕并想查看地图,或者我
可以在机场从我的手机上查看
当我想要的只是大门时打电话
数量。

这是有原因的。这似乎更喜欢非重定向方法,而是检测代理类型并显示适当的视图。

哪种方法更好还有待争论。

您可以通过让主站点根据代理类型响应视图来组合这些方法,同时还将内容放置在特定于移动设备的域中(不是复制它,只是将附加域映射到它),这将允许不发送消息的手机用于查看较轻的移动站点的移动用户代理字符串。

This is up to you.

Some sites put there mobile view on its own domain, e.g., m.yourdomain.com or yourdomain.mobi, and if a mobile user arrives at your non-mobile site (and are detected via agent-string) they'll be redirected to the mobile domain.

However, Tim Berner-Lee states:

It is fundamentally useful to be able
to quote the URI for some information
and then look up that URI in an
entirely different context. For
example, I may want to look up a
restaurant on my laptop, bookmark it,
and then, when I only have my phone,
check the bookmark to have a look at
the evening menu. Or, my travel agent
may send me a pointer to my itinerary
for a business trip. I may view the
itinerary from my office on a large
screen and want to see the map, or I
may view it at the airport from my
phone when all I want is the gate
number.

There's something to that. This seems to prefer a non-redirection approach but, instead, detecting the agent type and displaying the appropriate view.

Which approach is better is up for debate.

You could combine the approaches by having your main site respond with views based on agent type while also placing content in a mobile-specific domain (not duplicating it, just mapping the additional domain to it), which will allow phones that don't send a mobile user agent string to view the lighter mobile site.

顾挽 2024-10-01 06:27:25

两种方法同样有效。只需确保,为了可用性,您赋予用户在两个视图之间切换并使其具有粘性的能力。这样,使用 iPad 的用户并不总能获取移动模板,而获取移动网站 URL 的用户可以切换回桌面。

Both approaches are equally valid. Just make sure, for usability sake, that you give the user that ability to switch between the two views and make it sticky. That way, someone on their iPad doesn't always get the mobile template and someone who gets a url to the mobile site can switch back on their desktop.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文