Last active
August 7, 2023 03:13
-
-
Save tdavisjr/af0bc3468a33074cc64a639f40eebb29 to your computer and use it in GitHub Desktop.
Remove classic asp extension with URL Rewrite and outbound rule rewrite
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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