Redirecting based on file extension only

Hi! I’m trying to get my site to redirect RSS requests based on the file extension. This is the redirect rule I’ve got in my _redirects file:

/:tag.rss  /tags/:tag.rss

The problem is that it’s matching on any URL, including those that don’t end in .rss. For example, /foo redirects to /tags/foo.

I’m migrating from an old CMS that had RSS feeds at e.g. /foo.rss and they need to be redirected to /tags/foo.rss.

Hi, @samwilson, I think you are expecting a placeholder named :tag which matches <insert placeholder here >.rss. Instead the placeholder is :tag.rss and it matches any single path segment URL.

For these paths:

  • /foo.rss
  • /foo.css
  • /foo.html

This redirect will match all of everything after the “/” and store it in a placeholder named :tag.rss. This is what will match of each one above:

  • foo.rss
  • foo.css
  • foo.html

A placeholder will match everything between two “/” characters or from a “/” to the end of the path (up to but not including any GET parameters in the URL). It matches a whole “path segment”.

Take the URL below as an example:

The path of the URL above is:


The are three path segments which are:

  • path
  • to.some
  • page.rss

The redirect rule makes a placeholder named :tag.rss which matches anything with has only the initial “/” and no other path segments. It does not match URLs with more than one path segment.

For this URL:

The placeholder named :tag.rss is matching the first path segment which is the “foo” in /foo. Then on the target side of the redirect, the placeholder of :tag.rss is replaced with foo and redirecting to /tags/foo.

To summarize, the placeholder cannot match only a portion of a path segment, it must match the whole segment or nothing.