regexiisiis-10clean-urlspretty-urls

Using IIS Rewrite for Clean URLs: Any difference between matching "^" or ".*"?


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:

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?


Solution

  • In this context both mean the same: