2013-03-04 146 views
0

已經看過所有關於此的其他帖子,但似乎無法使其工作。有很多不相關的原因,爲什麼我無法更改Joomla配置,項目等,但無論如何,似乎這些應該工作,無論如何。htaccess重定向被「忽略」

總之,我想的itemid = 30在任何鏈接重定向到給出的一個。我究竟做錯了什麼?前三個是我試過的,最後一行是正在工作的。

RedirectMatch 301 ^Itemid=30$ http://inside.beta.oursite.com/index.php?option=com_cware&view=courses&Itemid=125 

redirect 301 index.php?option=com_cware&view=courses&Itemid=30 http://inside.beta.oursite.com/index.php?option=com_cware&view=courses&Itemid=125 

RewriteEngine On 
RewriteCond %{QUERY_STRING} Itemid=30 
RewriteRule ^Itemid=30/$ index.php?option=com_content&view=article&id=106&Itemid=121 [R=301] 


# If query string contains "username=admin" 
RewriteCond %{QUERY_STRING} username=admin 
# Block it without mercy 
RewriteRule .* - [F] 
+0

我在http://stackoverflow.com/questions/10135702/301-redirect-from-url-with-query-string-to-new-domain-with-different-query-找到解決方案 - 嚴格的,但不明白爲什麼重定向301 ....不工作,因爲我低頭並且它應該。 – GDP 2013-03-04 19:35:10

回答

1

RedirectRedirect僅考慮URL路徑,其中排除了查詢字符串。如果您想考慮查詢字符串,則必須使用mod_rewrite

同樣適用於RewriteRule

如果你想對陣的主機名,端口或查詢字符串,使用的RewriteCond與%{HTTP_HOST}%{SERVER_PORT}或%{QUERY_STRING}變量分別。

因此,如果你想匹配一些查詢字符串,所有的URL重定向到一些其他的URL,在組合使用的RewriteCond與重寫規則

RewriteEngine On 
RewriteCond %{QUERY_STRING} Itemid=30 
RewriteRule .* index.php?option=com_content&view=article&id=106&Itemid=121 [R=301] 

這重定向任何URL .*Itemid=30查詢字符串到index.php?option=com_content&...