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
The problem is that it’s matching on any URL, including those that don’t end in
.rss. For example,
/foo redirects to
I’m migrating from an old CMS that had RSS feeds at e.g.
/foo.rss and they need to be redirected to
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:
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:
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:
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
To summarize, the placeholder cannot match only a portion of a path segment, it must match the whole segment or nothing.
Came here trying to figure out if I could leverage a placeholder to match something before an image extension, i.e.
I want to redirect
But it sounds like this is not possible because a placeholder only matches what’s between
# this will redirect `/people/luke.png` to `https://domain.com/luke.png/128.png`
# this is kind of what I would hope for, but wouldn't work
@luke’s observation is very useful:
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)
So useful, that I could’ve skipped scouring the community if the “Placeholders” docs had stated this. Might be useful to add that bit of clarity in the docs?
Howdy @jimniels! We have filed a feature request for this and linked this thread to it. If we end up implementing this functionality, we will let you know!