I'd like to build a IIS url rewrite rule that matches several file extensions but ignore the query string.
Samples:
/hello.html // Match
/test?qs=world.html // Should not match
/test?qs=world.html&qs2=x // Should not match
Here is what I was using that does not work correctly:
<add matchType="Pattern" input="{HTTP_URL}" pattern=".+\.(js|css|less|html|eot|svg|ttf|woff|json|xml)$" negate="true" /> <!--Any url with a dot for file extension-->
Use
\w+
instead of.+
.................(\w
is equivalent to[a-zA-Z0-9_]
):If you want to allow other characters (non included in
\w
) and still ignore query string you can use[^?]+
instead of.+