当我从手机上点击时,我会尝试这样做,我会重定向到手机网站,而从pc上则意味着正常的网站。但是这些条件不能正常工作。
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_USER_AGENT} "{android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile}" [NC]
RewriteRule ^(.*)$ http://localhost:8080/home.html [L,R=301]
RewriteCond %{HTTP_USER_AGENT} "!{android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile}" [NC]
RewriteRule ^abc.html$ /abc1.html [R=301,L]
RewriteRule ^1.html$ /2.html [R=301,L]
</IfModule>当我在移动设备上点击localhost时,我正确地得到了移动网站,但如果我给了localhost/abc.html,第二个条件就会出现,但实际上它应该转到移动网站。代码有什么问题吗?
发布于 2012-07-09 17:25:10
与其说是一个ans,不如说是你的方法的一组要点:
RewriteBase /,因为如果你不最后,也是最重要的,为什么要做301重定向,而不是简单的内部重定向,这样就不需要额外的往返和/或301s的浏览器缓存?
RewriteCond %{HTTP_USER_AGENT} (android|blackberry|ipad|iphone|ipod|iemobile|opera mobile|palmos|webos|googlebot-mobile) [NC]
RewriteRule ^(.*)$ mobile/home.html [L]
RewriteRule ^abc.html$ abc1.html [L]
RewriteRule ^1.html$ 2.html [L]https://stackoverflow.com/questions/11389320
复制相似问题