I use IIS7 and say my site url is http://example.com

What I try to accomplish:

All web pages goes to WWW version.
All Https pages redirect to http protocol except for example.com/foobar/
If example.com/foobar has http infront, force it to use https.

Therefore I have the following in web.config:

<rule name="Redirect to WWW" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{HTTP_HOST}" pattern="^example.com$" />
</conditions>
<action type="Redirect" url="http://www.example.com/{R:0}" redirectType="Permanent" />
</rule>

<rule name="HTTPS to HTTP" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{SERVER_PORT}" pattern="^443$" />
<add input="{REQUEST_URI}" pattern="/foobar/" ignoreCase="true" negate="true" />
</conditions>
<action type="Redirect" url="http://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>

<rule name="Force HTTPS on foobar" stopProcessing="true">
<match url=".*" />
<conditions>
<add input="{REQUEST_URI}" pattern="/foobar/"/>
</conditions>
<action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
</rule>

For strange reason it won't work and browser telling me a redirect would never happen so a error page is thrown?