views:

222

answers:

3

How would I write a redirect rule that would let me use both http://www.site.com/rss and http://www.site.com/anydirectory/rss rather than http://www.site.com/rss.xml and http://www.site.com/anydirectory/rss.xml ?

I think I'm close, but for some reason, it's a Monday.

RewriteRule ^(.*)/rss.\xml/$ $1/rss [L]
+1  A: 

This is a guess, but it looks like you intended to escape the . and that is done with \. instead of .\

RewriteRule ^(.*)/rss\.xml$ $1/rss [L]
Dennis Palmer
Good catch on that Dennis, thank you. I was trying to escape it, but I must have mistyped. It's closer, but it's still not quite working.
VirtuosiMedia
+2  A: 

I think this is what you want (you have them reversed):

RewriteRule ^(.+/)?rss$ $1rss.xml [L]
Sean Bright
Thanks Sean, that did the trick.
VirtuosiMedia
+1  A: 

It sounds like you have the XML files, and you want to make URIs without the XML extension work.

# translate /rss to /rss.xml
RewriteRule ^rss$ /rss.xml 

# translate /anydirectory/rss to /anydirectory/rss.xml
RewriteRule ^(.+)/rss$ /$1/rss.xml

The code you tried suggests the opposite.

# translate /rss.xml to /rss
RewriteRule ^rss\.xml$ /rss 

# translate /anydirectory/rss to /anydirectory/rss.xml
RewriteRule ^(.+)/rss\.xml$ /$1/rss
Patrick McElhaney
+1 This also worked, thank you Patrick.
VirtuosiMedia