Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I am trying to configure a redirect for a specific path on our site. I don't want the whole site to be SSL.

For example I want any page at this path: http://www.mysite.com/sc/ to redirect to https://www.mysite.com/sc/

I tried the following web.config but it does not seem to work.

        <rewrite>
        <rules>
            <rule name="Force HTTPS public html" stopProcessing="true">
                <match url="/html/(.*)" />
                <conditions>
                    <add input="{HTTPS}" pattern="^OFF$" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}/{R:1}" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>        
share|improve this question

1 Answer 1

You are matching against the wrong URL. And the redirect is not correct. The following should work:

 <rewrite>
    <rules>
        <rule name="Force HTTPS for /sc folder" stopProcessing="true">
            <match url="^sc/" />
            <conditions>
                <add input="{HTTPS}" pattern="^OFF$" />
            </conditions>
            <action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
        </rule>
    </rules>
</rewrite>
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.