2012-07-22 48 views
0

我需要創建一個規則,爲所有GET請求來我的網站,這樣:的.htaccess規則:刪除參數

GET /articles/topic1.html?showall=1

被改寫爲:

GET /articles/topic1.html

我有我的Joomla網站下面的.htaccess文件:

RewriteEngine On 

RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|%3D) [OR] 
RewriteCond %{QUERY_STRING} base64_encode.*(.*) [OR] 
RewriteCond %{QUERY_STRING} (<|%3C).*script.*(>|%3E) [NC,OR] 
RewriteCond %{QUERY_STRING} GLOBALS(=|[|%[0-9A-Z]{0,2}) [OR] 
RewriteCond %{QUERY_STRING} _REQUEST(=|[|%[0-9A-Z]{0,2}) 
RewriteRule ^(.*)$ index.php [F,L] 

########## This is the Rule I have added ################ 
RewriteRule ^(.*)$ /$showall=1 [R=301,L] 

RewriteBase/

我在添加的行上添加了註釋。不幸的是,它不工作,瀏覽器警告我,我產生了一個循環...

任何想法如何解決它? 感謝 弗蘭克

回答

0

嘗試更換與:

RewriteCond %{QUERY_STRING} ^showall=([0-9])+$ 
RewriteRule ^articles/topic[0-9]*\.html /articles/topic%1.html? [L] 

或者,如果它真的topic1.html,那麼你想這樣的:

RewriteCond %{QUERY_STRING} ^showall=1$ 
RewriteRule ^articles/topic1\.html /articles/topic1.html? [L] 
+0

感謝您的回覆:只是有一點要注意的路徑/ articles/topic1.html純粹就是一個例子。實際上,路徑可能會有所不同,具體取決於主題。唯一的常量是我想要刪除的?showall = 1查詢參數。 – 2012-07-22 20:05:13