2011-12-20 214 views
0

任何人都可以幫助.htaccess URL重寫規則。.htaccess重定向規則

我需要重定向頁面是這樣的:

www.website.com/index.php?a=some-word-some-other-word 
www.website.com/index.php?a=something 
www.website.com/index.php?a=some-other-thing 

所有這些頁面具有相同內容www.website.com/index.php

www.website.com /index.php或www.website.com/

我已經問過這個,我得到了這個:

RewriteEngine On 
RewriteBase/

#if the query string has an a parameter 
RewriteCond %{QUERY_STRING} (^|&)a= [NC] 
#Redirect and remove query string parameters 
RewriteRule .* http://www.website.com/? [R=301,L] 

它這樣做,它將這些頁面重定向到主頁(網站的根)。但我有一些網址的網址如下:

i.php?a=something-something-something 

問題是上面的.htaccess代碼也會影響這些鏈接。

任何人都可以使該代碼只是基於index.php?a=而不是i.php?a=也重定向頁面的鏈接。

回答

1

試試這個,告訴我,如果它的工作原理:

RewriteEngine On 
RewriteBase/

#if the query string has an a parameter 
RewriteCond %{QUERY_STRING} (^|&)a= [NC] 
#Redirect and remove query string parameters 
RewriteRule ^index\.php$ http://www.website.com/? [R=301,L] 
+0

謝謝,它的工作原理。 – 2011-12-21 08:53:51

+0

如果有效,我可以請你檢查我的答案爲「有效」嗎? – 2011-12-21 09:17:22