除非用户想要"强制使用桌面版",否则使用htaccess重定向到移动版

Nic*_*las 1 apache .htaccess mobile web

我有以下.htaccess文件重定向到我的网站的移动版本:

RewriteEngine On
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://www.example.com/mobile [L,R=302]
Run Code Online (Sandbox Code Playgroud)

但是,我需要为移动用户添加条件才能请求桌面版网站.

我搜索了一下,没有找到一个简单的答案.我只需要有一个url,例如http://www.example.com/?desktop,以避免重定向到/ mobile

vme*_*eln 5

试试看:

RewriteEngine On
RewriteCond %{QUERY_STRING} !^desktop
RewriteCond %{HTTP_USER_AGENT} "android|blackberry|googlebot-mobile|iemobile|iphone|ipod|#opera mobile|palmos|webos" [NC]
RewriteRule ^$ http://www.example.com/mobile [L,R=302]
Run Code Online (Sandbox Code Playgroud)