I have the following IIS rewrite rules that work exactly as I wish on both my development and live servers within an Orchard CMS website, though when enabled, seriously slow the site's page loads. This is easily tested by enabling/disabling the rules to notice the performance decrease, which appears to accrue (i.e. not one rule more than others).
As these are the first rules I've ever created, I imagine there may be some obvious pitfalls, though my research hasn't lead me to discover any.
So simply put, what might be causing the slowdown in my page load times (...perhaps order?):
<rewrite>
<rules>
<rule name="www to non-www" enabled="true" stopProcessing="true">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^www.(.*)$" />
</conditions>
<action type="Redirect" url="http://{C:1}/{R:0}" redirectType="Permanent" />
</rule>
<rule name="Dont Process Any Further" enabled="true" stopProcessing="true">
<match url="^(about-us$|contact$|copyright$|privacy$|terms$|book$|surroundings$|
Admin|Media|Themes|Modules|Core|Users|Orchard|source
)" />
<!-- Match url, Line (1): user specific. Line (2): app specific -->
<action type="None" />
</rule>
<!--When root/url requested, goto _domain_index-->
<rule name="Rewrite - Root Hit Redirect" enabled="true">
<match url="^$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{HTTP_HOST}" pattern="^(www.)?brun.azurewebsites.net" negate="true" />
<add input="{HTTP_HOST}" pattern="^(www.)?brun.com" negate="true" />
<add input="{HTTP_HOST}" pattern="^(www.)?(.*).com" />
</conditions>
<action type="Rewrite" url="_{C:2}_index" />
</rule>
<!--Note: the first pattern in this rule stops the *possible* above rules URL
being rewritten again i.e _domain_index to _domain__domain_index, whilst
also allowing 'View' links from Orchards Dashboard to work-->
<rule name="Rewrite - /page to /_domain_page" enabled="true">
<match url="^(.*)" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="true">
<!--<add input="{REQUEST_URI}" pattern="/_([a-zA-Z]+)_index$" negate="true" />-->
<add input="{REQUEST_URI}" pattern="/_([a-zA-Z]+)_([a-zA-Z]+)$" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{HTTP_HOST}" pattern="^(www.)?brun.azurewebsites.net" negate="true" />
<add input="{HTTP_HOST}" pattern="^(www.)?brun.com" negate="true" />
<add input="{HTTP_HOST}" pattern="^(www.)?(.*).com" />
</conditions>
<action type="Rewrite" url="_{C:5}_{R:1}" />
</rule>
</rules>
</rewrite>