从移动网站与htaccess的重定向桌面用户望而却步望而却步、重定向、桌面、用户

2023-09-02 11:25:49 作者:花開灬若相惜

您好,在乡亲#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|operasmobile|palmos|webos) [NC]
RewriteRule ^ http://website.com%{REQUEST_URI} [L,R=302]