title: IIS url rewrite rewriting all .asp to .html
body: <p>I need to create rules for web.config that will rewrite all requests for files with extension .html to .asp and redirect all .asp requests to .html</p>
  
  <p>Example:<br>
  file_xyz.asp rewrites to file_xyz.html <br>
  directory1/file_xyz.asp rewrites to directory1/file_xyz.html<br> 
  and </p>
  
  <p>file_xyz.html  redirects to file_xyz.asp <br>
  directory1/file_xyz.html redirects to directory1/file_xyz.asp</p>
  
  <ol>
  <li>What is the syntax for the rule</li>
  <li>Is this too broad a rule?  If I should need for what ever reason to have a physical file such as file_abc.html how do I exclude it from the redirect rule? </li>
  <li>I am thinking I should just use ISAPI_Rewrite <a href="http://www.isapirewrite.com/" rel="nofollow noreferrer">http://www.isapirewrite.com/</a> there seems to be a ton of resources out there for rewriting with htaccess and very little online help for using IIS 7 URL rewrite. Any thoughts and/or advice</li>
  </ol>
  
  <p>Thanks in advance</p>
  
  <p>So far this is the syntax I have for the web.config</p>
  
  <pre><code>&lt;rule name="RewriteHTMLtoASP" stopProcessing="true"&gt;
    &lt;match url="^([^/]+)\.html$" /&gt;
    &lt;conditions logicalGrouping="MatchAll" /&gt;
    &lt;action type="Rewrite" url="{R:1}.asp" /&gt;
    &lt;/rule&gt;
   &lt;rule name="RedirectASPtoHTML" stopProcessing="true"&gt;
      &lt;match url="^([^/]+)\.asp$" /&gt;
       &lt;conditions logicalGrouping="MatchAll"&gt;
       &lt;add input="{REQUEST_METHOD}" pattern="^GET$" /&gt;
       &lt;/conditions&gt;
       &lt;action type="Redirect" url="{R:1}.html" appendQueryString="false" /&gt;
     &lt;/rule&gt;
  </code></pre>