title: Web.config iis url rewrite
body: <p>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).</p>
  
  <p>My IIS Rewrite Rule works, but I don't want to have to remember to change <code>localhost</code> to my server hosting address once I deploy the website. Any suggestions?</p>
  
  <p>Below are my IIS URL Rewrite rules in <code>&lt;system.webServer&gt;</code></p>
  
  <blockquote>
    <p></p>
  </blockquote>
  
  <pre><code>&lt;!-- IIS Rules Rewrite --&gt;
  &lt;rewrite&gt;
    &lt;rules&gt;  
  &lt;!-- Serve site map with proper XML content type response header. --&gt;
      &lt;rule name="Sitemap XML" enabled="true" stopProcessing="true"&gt;
        &lt;match url="sitemap.xml" /&gt;
        &lt;action type="Rewrite" url="sitemap.aspx" appendQueryString="false"/&gt;
      &lt;/rule&gt;
      &lt;!-- 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 --&gt;
      &lt;rule name="Fail bad requests"&gt;
        &lt;match url=".*"/&gt;
        &lt;conditions&gt;
          &lt;add input="{HTTP_HOST}" pattern="localhost" negate="true" /&gt;
        &lt;/conditions&gt;
        &lt;action type="AbortRequest" /&gt;
      &lt;/rule&gt;
      &lt;!-- HTTP to HTTPS Rule 
      &lt;rule name="Redirect to https" enabled="true" patternSyntax="Wildcard" stopProcessing="true"&gt;
        &lt;match url="*" negate="false" /&gt;
        &lt;conditions logicalGrouping="MatchAny"&gt;
          &lt;add input="{HTTPS}" pattern="off" /&gt;
        &lt;/conditions&gt;
        &lt;action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Found" /&gt;
      &lt;/rule&gt;--&gt;
  </code></pre>