我的.htaccess现在看起来像这样:
RewriteCond %{HTTP_USER_AGENT} Opera
RewriteCond %{QUERY_STRING} aid=(?:[0-9]{1,3}|1000)
<If "%{QUERY_STRING} == 'aid=001'">
RewriteRule ^/(.*) http://m.example1.com/? [L,R=302]
</If>
<ElseIf "%{QUERY_STRING} == 'aid=002'">
RewriteRule ^/(.*) http://m.example2.com/? [L,R=302]
</ElseIf>
...
但是,当我使用chrome访问我的网站http://test.com/article-title?aid=001时,我也会被重新编辑。 Normaly我只能在使用opera时重定向。
我做错了什么?
立即更新我的htaccess看起来像这样:
RewriteEngine On
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END
RewriteCond %{QUERY_STRING} aid=(?:[0-9]{1,3}|1000)
<If "%{QUERY_STRING} == 'aid=001'">
RewriteCond %{HTTP_USER_AGENT} Opera
RewriteRule ^/(.*) http://m.example1.com/? [L,R=302]
</If>
<ElseIf "%{QUERY_STRING} == 'aid=002'">
RewriteCond %{HTTP_USER_AGENT} Opera
RewriteRule ^/(.*) http://m.example2.com/? [L,R=302]
</ElseIf>
我也试过这个
RewriteEngine On
RewriteCond %{QUERY_STRING} aid=(?:[0-9]{1,3}|1000)
<If "%{QUERY_STRING} == 'aid=001'">
RewriteCond %{HTTP_USER_AGENT} Opera
RewriteRule ^/(.*) http://m.example1.com/? [L,R=302]
</If>
<ElseIf "%{QUERY_STRING} == 'aid=002'">
RewriteCond %{HTTP_USER_AGENT} Opera
RewriteRule ^$ http://m.example2.com/ [L,R=302]
</ElseIf>
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END
答案 0 :(得分:1)
您无法将if/elseif
条件之外的条件与内部条件相结合。用它作为:
RewriteEngine On
RewriteBase /
RewriteCond %{QUERY_STRING} (^|&)aid=001(&|$) [NC]
RewriteCond %{HTTP_USER_AGENT} opera [NC]
RewriteRule ^ http://m.example1.com/? [NE,L,R=302]
RewriteCond %{QUERY_STRING} (^|&)aid=002(&|$) [NC]
RewriteCond %{HTTP_USER_AGENT} opera [NC]
RewriteRule ^ http://m.example2.com/? [L,R=302]
# BEGIN WordPress
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
# END
答案 1 :(得分:0)
在您的解释之后,我认为您可以在本网站detectmobilebrowsers.com
找到答案