2013-04-04 155 views
1

首先,我檢查了關於該主題的老問題,但我無法讓它繼續工作。動態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> 

回答

0

啊是啊,我忘了,我已經聲明改寫基地。所以,它應該是:的

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

解決。

+1

它不應該工作。規則中檢查的URI路徑沒有前導斜槓('^/index'),因此無法將其添加到正則表達式進行比較。我不認爲它按預期工作。 – 2013-04-04 12:56:37

0

把這些線路只是你RewriteBase線以下:

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

並註釋掉你的2線下方WordPress的規則。