.htaccess - redirect one file to two differents files depending on the presence of a query string -
i'm in process of migrating blog new platform (dotclear > drupal) , i'm trying redirect old urls rss feeds new feeds.
there 2 types of feeds (articles or comments), each in 2 flavors (rss or atom), that's 4 urls redirect.
my problem comes fact feeds comments same articles, plus query-string (?type=co
). here rules have:
redirect 301 /blog/rss.php?type=co /rss-comments.xml redirect 301 /blog/rss.php /rss.xml redirect 301 /blog/atom.php?type=co /rss-comments.xml redirect 301 /blog/atom.php /rss.xml
this works fine articles feeds (without query-string), rules comments feeds seem ignored , redirect article feed (useless) query-string.
so /blog/rss.php?type=co
rewritten /rss.xml?type=co
instead of /rss-comments.xml
.
what doing wrong?
tried changing order of rules, same effect...
you can't match query string using redirect
directive. use rewriterule
this:
rewritecond %{query_string} ^type=co$ [nc] rewriterule ^blog/(rss|atom)\.php$ /rss-comments.xml? [l,nc,r=301] rewritecond %{query_string} ^$ [nc] rewriterule ^blog/(rss|atom)\.php$ /rss.xml [l,nc,r=301]