dongtan2603 2011-10-14 15:24
浏览 48
已采纳

Htaccess不会将移动用户重定向到domain.com/m

My page can be accessed through domain.com or www.domain.com
I am trying to have a redirect for users on mobile devices to the domain.com/m or *www.domain.com/m*

However I am having difficulties to do this correctly. I have put this in my .htaccess on index.php of domain.com

How to do this correctly?

RewriteCond %{REQUEST_URI} !^/http://www.domain.com/.*$
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile" [NC]
RewriteRule ^(.*)$ /m/ [L,R=302]
  • 写回答

4条回答 默认 最新

  • douwei7501 2011-10-14 15:27
    关注

    Try this:

    RewriteCond %{HTTP_USER_AGENT} "android" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "blackberry" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "ipad" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "iphone" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "ipod" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "iemobile" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "opera mobile" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "palmos" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "webos" [NC,OR]
    RewriteCond %{HTTP_USER_AGENT} "googlebot-mobile" [NC]
    RewriteRule ^(.*)$ /m/ [L,R=302]
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 YOLO检测微调结果p为1
  • ¥20 求快手直播间榜单匿名采集ID用户名简单能学会的
  • ¥15 DS18B20内部ADC模数转换器
  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题