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!

Donald Burr
  • 103
  • 4

1 Answers1

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.

paulmorriss
  • 15,371
  • 1
  • 38
  • 58
milo5b
  • 1,081
  • 7
  • 12