Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.

This is probably a mind-numbingly simple question, but for some reason mod_rewrite always manages to completely befuddle me every time I interact with it.

A long time ago when I set up my blog and podcast, I didn't yet grasp the whole concept of permalinks; and so the RSS feed URL that I submitted to iTunes was of the form:

http://otakunopodcast.com/?feed=podcast (note the question mark)

Now that I have permalinks set up properly, my RSS feed url is now:

http://otakunopodcast.com/feed/podcast (note the lack of ugly question marks ;-) )

So I would like to write a mod_rewrite rule to convert from the former to the latter, generating a 301 in the process. However every attempt I have made to do so has either ended up in it not working, or worse, causing a rewrite loop.

Any and all help gratefully appreciated. Thanks!

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted
RewriteCond %{REQUEST_URI}  ^/$
RewriteCond %{QUERY_STRING} ^feed=podcast$
RewriteRule ^(.*)$ /feed/podcast [R=301,L]

This works because everything after the ? is the query string, and this rule takes effect when there is a question mark with feed=podcast after it.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.