I'm creating a rewrite rule in an IIS (v10.0) configuration file to enable clean URLs ("pretty URLs") by capturing all incoming requests and routing anything that doesn't specifically match a physical directory or file in the system to a single point for processing. The rule currently looks like this:
<rule name="Absorbifier" stopProcessing="true">
<match url="^" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
</conditions>
<action type="Rewrite" url="index.php" appendQueryString="true" />
</rule>
I've found several good examples of people writing similar rules, and the most popular regex patterns I've seen for capturing all requests are these two:
^
(Match from the beginning of any string).*
(Match 0 or more of any character except line breaks)I've tested each of these patterns and have not yet seen any difference in how they perform. Within the context of the rule I'm writing, do these turn out to be functionally equivalent? Or is one of them better at capturing hard to predict edge cases?
In this context both mean the same:
^
means beginning of a string, and is a match, even for an empty string..*
means everything up to next newline, and is a match, even for an empty string.