重定向移动设备的最佳方式

编程入门 行业动态 更新时间:2024-10-19 04:24:07
本文介绍了重定向移动设备的最佳方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

Possible Duplicate: Mobile Redirect using htaccess

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

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

还有的将是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\ [NC] RewriteCond %{HTTP_USER_AGENT} "android|blackberry|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC] RewriteRule ^(.*)$ m.mydomain/$1 [L,R=302]

更多推荐

重定向移动设备的最佳方式

本文发布于:2023-11-17 02:06:48,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1608416.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:重定向   方式   设备

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!