I am trying to add a iis url rewrite rule that differs in the development environment (on my local machine) and once uploaded to the server and published (deployed).
My IIS Rewrite Rule works, but I don't want to have to remember to change localhost to my server hosting address once I deploy the website. Any suggestions?
Below are my IIS URL Rewrite rules in <system.webServer>
<!-- IIS Rules Rewrite -->
<rewrite>
<rules>
<!-- Serve site map with proper XML content type response header. -->
<rule name="Sitemap XML" enabled="true" stopProcessing="true">
<match url="sitemap.xml" />
<action type="Rewrite" url="sitemap.aspx" appendQueryString="false"/>
</rule>
<!-- Access block rule - is used to block all requests made to a Web site if those requests do not have the host header set. This type of rule is useful when you want to prevent hacking attempts that are made by issuing HTTP requests against the IP address of the server instead of using the host name -->
<rule name="Fail bad requests">
<match url=".*"/>
<conditions>
<add input="{HTTP_HOST}" pattern="localhost" negate="true" />
</conditions>
<action type="AbortRequest" />
</rule>
<!-- HTTP to HTTPS Rule
<rule name="Redirect to https" enabled="true" patternSyntax="Wildcard" stopProcessing="true">
<match url="*" negate="false" />
<conditions logicalGrouping="MatchAny">
<add input="{HTTPS}" pattern="off" />
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" />
</rule>-->