IIS7 Rewrite Map Regex?
Asked Answered
D

1

11

Is it possible to use reg ex in a rewrite map? For example:

<rewriteMap name="Redirects">
   <add key="/blah/(.*)" value="/blah/{R:1}" />
</rewriteMap>

Or is there a way to handle this approach? Currently, I have a rule set up to match on everything and then use the rewrite map to map to new urls. I would like to capture everything under a directory e.g. resource files (blah)... without having to manually to do this for them all.

Darksome answered 11/4, 2012 at 11:21 Comment(1)
i'm sure you've already read it, but just incase, there is some helpful stuff here: learn.iis.net/page.aspx/465/…Magnetohydrodynamics
B
3

Unfortunately not, you'll need to create a rule to use regular expressions.

Notice that there is no obvious common pattern in the keys and their relation to values. This means that it is not possible to use regular expressions or wildcards to define URL transformation logic. http://www.iis.net/learn/extensions/url-rewrite-module/using-rewrite-maps-in-url-rewrite-module

Bicarb answered 29/11, 2012 at 16:36 Comment(3)
The mention that you quote here is a reference to the examples they're giving earlier in that page, so I don't believe it's a "regex will never work" so much as "regex won't work for this example". That said, I can't find any information about whether or not regex will work "ever", as the documentation for rewrite maps appears to be non-existent :/Polyvalent
I correct myself — the documentation is not non-existent, but it's not very comprehensive. There is more documentation at URL Rewrite Module Configuration Reference, though it does not address this point.Polyvalent
I think a better quote is from the summary: "The rewrite maps allow you to reduce the number of rewrite rules when rewrite and redirect URL's are static and rewriting logic cannot be expressed by using any pattern matching techniques."None

© 2022 - 2024 — McMap. All rights reserved.