重定向移动设备的最佳方式 [英] Best way to redirect mobile devices

查看:203
本文介绍了重定向移动设备的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:
  使用移动重定向htaccess的

Possible Duplicate:
Mobile Redirect using htaccess

目前我有一个正规的网站,利用LAMP。我想重定向为移动设备添加到一个子域,像这样:m.mydomain.com

Currently I have a regular website, utilizing LAMP. I'd like to add a redirect for mobile devices to a subdomain, something like: m.mydomain.com

还有的将是PC和移动设备之间的内容部分的内容不同。

There's going to be some content differences between the content for PC and mobile devices.

什么是做到这一点的最好方法是什么?可以用.htaccess文件来实现还是需要某种形式的PHP脚本的?

What is the best way to do that? Can it be done with .htaccess file or do I need some sort of PHP script?

感谢。

推荐答案

我想的.htaccess将是最快的。你可以把这样的事情在你的htaccess文件。

I think .htaccess would be the fastest. you might put something like this in your htaccess file.

RewriteCond %{HTTP_HOST} ^www\.mydomain\.com [NC]
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ http://m.mydomain.com/$1 [L,R=302]

这篇关于重定向移动设备的最佳方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆