Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I have several Redirect directives in my Ubuntu /etc/apache2/sites-available file:

    Redirect 301 /rss.xml http://example.com/feed/index.xml
    Redirect 301 /atom.xml http://example.com/feed/atom/index.xml
    Redirect 301 /feed/ http://example.com/feed/index.xml
    Redirect 301 /feed http://example.com/feed/index.xml

They all work correctly, so far as I can tell.

However, when I visit http://example.com/feed/index.xml with web-sniffer.net, it returns a 301 pointing at http://example.com/feed/index.xmlindex.xml, which then gets redirected to http://example.com/feed/index.xmlindex.xmlindex.xml, and so forth.

It seems that one of the patterns is matching when I don't expect it to. If I omit the last two redirects, the looping is stopped, but then I'm not redirecting /feed and /feed/ when I should.

Any ideas of how make this work correctly?

(I think the problem is related to this question: http://serverfault.com/questions/155028/infinite-redirect-loop)

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Redirect is simple prefix matching and "[a]dditional path information beyond the matched URL-Path will be appended to the target URL."

Thus /feed/index.xml matches your third rule /feed/ with additional path information index.xml so it gets redirected to /feed/index.xml with index.xml appended to it.

The solution is to use RedirectMatch and use anchors:

RedirectMatch 301 ^/rss.xml$ http://example.com/feed/index.xml
RedirectMatch 301 ^/atom.xml$ http://example.com/feed/atom/index.xml
RedirectMatch 301 ^/feed/$ http://example.com/feed/index.xml
RedirectMatch 301 ^/feed$ http://example.com/feed/index.xml
share|improve this answer
Thank you, sir or madam! That did the trick. I don't know why I found that so difficult-- it's clearly in the docs here: httpd.apache.org/docs/2.2/mod/mod_alias.html#redirectmatch –  pingswept Sep 30 '10 at 19:06

Your Answer


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.