Using IIS Url Rewrite, is it possible to match wildcard URLs using RewriteMaps? For example, I have the following rewrite rule:
<rule name="Disable access except for RewriteMap URLs" enabled="true" stopProcessing="true">
<conditions>
<add input="{Allowed Urls:{URL}}" pattern="1" negate="true" />
</conditions>
<match url="(.*)" />
<action type="Redirect" url="http://{HTTP_HOST}" />
</rule>
which uses the following RewriteMap:
<rewriteMap name="Allowed Urls">
<add key="/products" value="1" />
<add key="/products/product-1" value="1" />
<add key="/products/product-2" value="1" />
</rewriteMap>
I'd like to amend my RewriteMap to include a wildcard URL so I have one add
element which matches the following URLs:
/products/id/1
/products/id/2
/products/id/3
/products/id/4
Is something like this possible?
I fixed the issue by adding an additional condition to my RewriteRule as follows:
<rule name="Disable access except for RewriteMap URLs" enabled="true" stopProcessing="true">
<conditions>
<add input="{Allowed Urls:{URL}}" pattern="1" negate="true" />
<add input="{REQUEST_URI}" negate="true" pattern="^/products/id/(.*)" ignoreCase="true" />
</conditions>
<match url="(.*)" />
<action type="Redirect" url="http://{HTTP_HOST}" />
</rule>