从手机启动时,如何将 wb 网站访问者重定向到 m.mydomain.com 版本?

发布于 2024-09-26 15:11:21 字数 154 浏览 0 评论 0原文

当访问者通过手机查看您的网站时,我(或您会)如何重定向访问您网页的访问者?

我想建立一个具有(标准?)m 的网站。前缀。

通常,当访问者使用手机访问我的网站时,我希望他们被重定向到这些页面吗?

我使用的是 Windows IIS6 和 IIS7。

How can I (or would you) redirect visitors visiting your web pages when they are viewing your site from a mobile phone ?

I want to set up a site with the (standard?) m. prefix.

Idially I would my visitors to be redirected to these pages when they visit my site using a mobile phone ?

I am using Windows IIS6 and IIS7.

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

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

发布评论

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

评论(2

通知家属抬走 2024-10-03 15:11:22

您可以检查请求标头中发送的 HTTP_USER_AGENT 字符串。这对于每个浏览器的每个版本都是唯一的。例如,您可以检查 HTTP_USER_AGENT 中是否存在“iPhone”来识别 iPhone 用户。您需要识别所有手机浏览器。

或者您可以检查用户视口的尺寸。如果小于一定尺寸则直接转到“移动”手机版本?

只是一个想法......随着手机浏览器变得越来越强大,是否总是需要访问该网站的手机版本?例如,iPhone 4 的分辨率高达 960x640!但我想它的外形仍然很小,用户可能会以不同的方式与它进行交互。

You could check the HTTP_USER_AGENT string sent in the request header. This is unique for each version of each browser. For instance you could check for the presence of 'iPhone' in the HTTP_USER_AGENT to identify iPhone users. You would need to identify all mobile phone browsers.

Or you could check the dimensions of the users viewport. If smaller than a certain size then direct to the 'mobile' phone version?

Just a thought... with mobile phone browsers getting ever more powerful is there always a need to go to a mobile phone version of the site? For instance the iPhone 4 has a massive 960x640 resolution! But I guess it is still a small form factor and users probably interact with it differently.

硬不硬你别怂 2024-10-03 15:11:22

我自己的网页需要这个。我评估了几个现有的移动用户代理检测器,并创建了我自己的一个小型 PHP 脚本。不确定 PHP 是否适合您。如果没有,这些原则可能可以轻松移植到另一种语言/系统。您可以在我的博客上找到信息

I needed this for my own webpage. I evaluated several existing mobile user agent detectors, and created a small PHP script of my own. Not sure if PHP is an option for you. If not, the principles can probably be ported easily to another language/system. You can find the info on my blog.

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