动态URL重定向htaccess

问题描述:

首先,我检查了关于该主题的老问题,但我无法让它继续工作。动态URL重定向htaccess

我基本上要:

http://example.com/example/?test=3重定向到http://www.yahoo.com

我:

# BEGIN WordPress 
<IfModule mod_rewrite.c> 
RewriteEngine On 
RewriteBase /example/ 
RewriteRule ^index\.php$ - [L] 
RewriteCond %{REQUEST_FILENAME} !-f 
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteRule . /example/index.php [L] 

RewriteCond %{QUERY_STRING} ^test=3$ [NC] 
RewriteRule ^/example/index\.php$ http://www.yahoo.com [L,R=301] 
</IfModule> 

啊是啊,我忘了,我已经声明改写基地。所以,它应该是:的

RewriteRule ^/index\.php$代替RewriteRule ^/example/index\.php$

解决。

+1

它不应该工作。规则中检查的URI路径没有前导斜杠('^/index'),因此无法将其添加到正则表达式进行比较。我不认为它按预期工作。 – 2013-04-04 12:56:37

把这些线路只是你RewriteBase线以下:

RewriteCond %{QUERY_STRING} ^test=3$ [NC] 
RewriteRule ^example/(index\.php|)$ http://www.yahoo.com? [L,R=301,NC] 

并注释掉你的2线下方WordPress的规则。