.htaccess htaccess中没有移动重定向的重定向规则

.htaccess htaccess中没有移动重定向的重定向规则,.htaccess,redirect,mobile,.htaccess,Redirect,Mobile,我使用.htaccess代码进行移动重定向: RewriteEngine On RewriteCond %{HTTP_USER_AGENT} (mobile|android|iphone|ipod|ipad|avantgo|blackberry|blazer|compal|elaine|epoc|fennec|hiptop|iemobile|iris|kindle|sgh|brew|htc|j2me|lg|midp|mmp|mot|netfront|nokia|obigo|openweb|op

我使用.htaccess代码进行移动重定向:

RewriteEngine On

RewriteCond %{HTTP_USER_AGENT} (mobile|android|iphone|ipod|ipad|avantgo|blackberry|blazer|compal|elaine|epoc|fennec|hiptop|iemobile|iris|kindle|sgh|brew|htc|j2me|lg|midp|mmp|mot|netfront|nokia|obigo|openweb|operamini|palm|plucker|pocket|psp|samsung|sanyo|sch|smartphone|sonyericsson|symbian|symbos|teleca|treo|up.browser|up.link|vodafone|wap|wap1|wap2|webos|windowsce|xda|xiino) [NC]
RewriteRule ^(.*)$ some site [R=302,L]
但是,我希望一些移动IP/移动用户代理被排除在上述重定向之外,而不是被拒绝。我想让他们看到桌面网站。 如何使用.htaccess代码实现这一点


谢谢。

您可以添加另一个
RewriteCond
以排除:

RewriteEngine On

RewriteCond %{REMOTE_ADDR} !^(11\.22\.33\.44|55\.66\.77\.88)$
RewriteCond %{HTTP_USER_AGENT} !(excluded-agent1|excluded-agent2|excluded-agent3)
RewriteCond %{HTTP_USER_AGENT} (mobile|android|iphone|ipod|ipad|avantgo|blackberry|blazer|compal|elaine|epoc|fennec|hiptop|iemobile|iris|kindle|sgh|brew|htc|j2me|lg|midp|mmp|mot|netfront|nokia|obigo|openweb|operamini|palm|plucker|pocket|psp|samsung|sanyo|sch|smartphone|sonyericsson|symbian|symbos|teleca|treo|up.browser|up.link|vodafone|wap|wap1|wap2|webos|windowsce|xda|xiino) [NC]
RewriteRule ^ /desktop-site [R=302,L]

谢谢你,阿努巴瓦!不,我代码中的“某个站点”是移动站点,没有桌面。我希望我的代码中的所有用户代理被重定向到我的手机-“某个站点”,排除在外的移动代理传递代码并查看我的桌面站点。这如何才能与IP地址推动?对不起,我能够理解您的评论。这个答案是针对这个要求
我希望排除一些移动IP/移动用户代理
。如果要阻止某些IP,请使用
RewriteCond%{REMOTE\u ADDR}
条件。对不起,anubhava!我不想阻止某些移动用户代理或IP,我想将他们排除在移动重定向之外,即他们必须以桌面用户而不是移动用户的身份查看网站。我必须使用什么条件才能使用这样的IP?Anubhava,我尝试了你的代码,但不起作用。你还有其他建议吗?非常感谢,阿努巴瓦!这对我帮助很大!