Skip to content

Instantly share code, notes, and snippets.

@tdavisjr
Last active August 7, 2023 03:13
Show Gist options
  • Save tdavisjr/af0bc3468a33074cc64a639f40eebb29 to your computer and use it in GitHub Desktop.
Save tdavisjr/af0bc3468a33074cc64a639f40eebb29 to your computer and use it in GitHub Desktop.
Remove classic asp extension with URL Rewrite and outbound rule rewrite
<rewrite>
<rules>
<rule name="Remove .asp Extension" stopProcessing="true">
<match url="^(.*?)(\.asp)$" />
<action type="Redirect" url="{ToLower:{R:1}}" appendQueryString="true" redirectType="Permanent" />
</rule>
<rule name="Rewrite to .asp" stopProcessing="true">
<match url="^(.*)$" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
<add input="{REQUEST_FILENAME}.asp" matchType="IsFile" />
</conditions>
<action type="Rewrite" url="{ToLower:{R:1}}.asp" />
</rule>
</rules>
<outboundRules>
<rule name="RewriteLinksAndFormTagsWithFriendlyURLs" preCondition="ResponseIsHtml1" enabled="true">
<match filterByTags="Form" pattern="^(.*)\.asp(.*)$" />
<action type="Rewrite" value="{R:1}{R:2}" />
</rule>
<preConditions>
<preCondition name="ResponseIsHtml1">
<add input="{RESPONSE_CONTENT_TYPE}" pattern="^text/html" />
</preCondition>
</preConditions>
</outboundRules>
</rewrite>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment