How does one use the built in IIS URL Rewrite SEO rule that adds trailing slash only to files that exist?
- by Sn3akyP3t3
The default rule template is AddTrailingSlash. I've added another condition that allows the rule to apply to directories and not files, but I'm not sure if this is industry standard.
Added:
The rule allows for filename that are not standard such as .mobileconfig
The web.config contains this rule when the template is applied:
<rule name="AddTrailingSlashRule1" enabled="true" stopProcessing="true">
<match url="(.*[^/])$" />
<conditions logicalGrouping="MatchAll" trackAllCaptures="false">
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" pattern="^.*\.[a-z]{1,12}" negate="true" />
</conditions>
<action type="Redirect" url="{R:1}/" />
</rule>