문제

I'm trying to redirect a list of URLs, but any of them that have a ? it isn't working. For example, here's my line of code...

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

This doesn't redirect. However, if I use this...

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

...or this...

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

...and test the URLs out, they redirect correctly.

Any ideas on how to get this working?

도움이 되었습니까?

해결책

You can't match query string using Redirect directive. Use mod_rewrite instead:

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]
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top