Exclude subdirectory from rewrite rule in web.config

Posted by Clog on Stack Overflow See other posts from Stack Overflow or by Clog
Published on 2011-01-09T17:50:41Z Indexed on 2011/01/09 17:53 UTC
Read the original article Hit count: 203

Filed under:
|
|
|

This question comes up often, but I can only find solutions for PHP, Apache, htaccess etc but not for web.config

I would like my pages to return in HTTP not HTTPS, except for forms within certain subdirectories. I have created the following web.config file, but how do I exclude a subdirectory called forms.

<configuration>
  <system.webServer>
<rewrite>
        <rules>
            <rule name="Force all to HTTP" stopProcessing="true">
 <match url="(.*)" /> 
     <conditions>
      <add input="{HTTPS}" pattern="on" ignoreCase="true" />
    </conditions>
  <action type="Redirect" redirectType="Found" url="http://www.mysite.com/{R:1}" />
</rule>
        </rules>
    </rewrite>
          </system.webServer>
</configuration>

Many thanks all you clever clogs.

© Stack Overflow or respective owner

Related posts about http

Related posts about web-config