2014-01-27 20 views
1

我想重定向的URL列表,但其中任何有一個?它不工作。例如,這裏是我的代碼行...Htaccess無法使用?

Redirect 301 /calendar-of-events/day/date/2013-03-28/227.html?print=1&tmpl=component https://example.com/index.php/calendar/ 

這個不重定向。但是,如果我用這個...

Redirect 301 /calendar-of-events/day/date/2013-03-28/227.html https://example.com/index.php/calendar/ 

...或...這

Redirect 301 /calendar-of-events/day/date/2013-03-28/227.html&tmpl=component https://example.com/index.php/calendar/ 

...和測試的網址了,他們正確地重定向。

有關如何使這項工作的任何想法?

回答

2

使用Redirect指令無法匹配查詢字符串。使用mod_rewrite改爲:

RewriteEngine On 

RewriteCond %{QUERY_STRING} ^print=1&tmpl=component$ [NC] 
RewriteRule ^calendar-of-events/day/date/2013-03-28/227\.html$ https://example.com/index.php/calendar/? [L,R=301] 
+1

非常感謝。這工作! – user1083385

+0

不客氣,很高興它解決了。 – anubhava