Using Intelligencia UrlRewriter regex for rewriting URLs
-
15-04-2021 - |
Question
I'm trying to use regex expressions to catch some incoming urls, but I'm having trouble putting the right expression together.
Basically I'm trying to rewrite
mydomain.com/abc12
into
mydomain.com/default.aspx?referrer=abc12
The extension will always be a 5 character [a-z0-9]
code, and I can't work out how to match only that specific combination. Anything I write seems to catch all my CSS files and everything as well.
Really I just need to grab that 5 char code, so if you have other suggestions as to how to do that I'm open to other recommendations as well.
Solution
Try to describe the pattern you want to find as good as possible
Maybe something like this:
mydomain\.com/([a-z0-9]{5})$
The quantifier {5}
enforces exactly 5 characters and the anchor $
enforces the end of the string after your code.
See it here on Regexr