从移动网站与htaccess的重定向桌面用户望而却步 [英] Redirect desktop users away from mobile site with .htaccess

查看:203
本文介绍了从移动网站与htaccess的重定向桌面用户望而却步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,在乡亲#1,

我期待台式机用户重定向远离移动站点的.htaccess:

I'm looking to redirect desktop users away from mobile site with .htaccess:

我已经有这个code这完美的作品,当移动用户试图访问我的网站,比如移动版:m.website.com

I already have this code which works perfectly when a mobile user tries to access the mobile version of my website example: m.website.com.

RewriteEngine On
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://m.website.com [L,R=302] 

但是,如果在桌面浏览器的用户类型m.website.com,它直接到移动版本的内容。

However if a user types m.website.com on a desktop browser, it goes directly to the mobile version content.

有没有办法添加任何额外的code到.htaccess文件,使之在某种程度上工作当桌面用户试图去m.website.com它仍保留在桌面版本。

Is there a way to add any additional code to the .htaccess file to make it work in a way that when a desktop user attempts to go to m.website.com it remains in the desktop version.

推荐答案

将在的.htaccess 这个附加规则 DOCUMENT_ROOT m.website.com

RewriteEngine On

RewriteCond %{HTTP_HOST} ^m\. [NC]
RewriteCond %{HTTP_USER_AGENT} !(android|blackberry|googlebot-mobile|iemobile|iphone|ipod|opera\smobile|palmos|webos) [NC]
RewriteRule ^ http://website.com%{REQUEST_URI} [L,R=302] 

这篇关于从移动网站与htaccess的重定向桌面用户望而却步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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