0

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!

1 Answer 1

4
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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