Mobile app version of vmapp.org
Login or Join
Steve110

: Using mod_rewrite to rewrite URLs with question marks in them This is probably a mind-numbingly simple question, but for some reason mod_rewrite always manages to completely befuddle me every time

@Steve110

Posted in: #ModRewrite

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:
otakunopodcast.com/?feed=podcast (note the question mark)

Now that I have permalinks set up properly, my RSS feed url is now:
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!

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Steve110

1 Comments

Sorted by latest first Latest Oldest Best

 

@Goswami781

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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme