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

my current configuration is:

<rule name="Force HTTPS" enabled="true">
    <match url="(.*)" ignoreCase="false" />
    <conditions>
        <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action 
        type="Redirect" 
        url="https://{HTTP_HOST}{R:1}" 
        appendQueryString="true" 
        redirectType="Permanent" />
</rule>

and links to the http do not work. but when you type in the direct (main) url, the rule described above does work. The links listed on Google do not work; they are without https but the rule should redirect them right? I don't get it.

when I go directly to an image example: http://www.domain.com/img.jpg that does not work. https does (when entered manually) what did I do wrong?

Now I have found this website with a sample: http://www.sslshopper.com/iis7-redirect-http-to-https.html

<rule name="HTTP to HTTPS redirect" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true" />
    </conditions>
    <action 
        type="Redirect" 
        url="https://{HTTP_HOST}/{R:1}" 
        redirectType="Found" />
</rule>

but that doesn't look so much different. why does my config not redirect google links and direct links to images, but does redirect the main domain. all direct deep links to pages do not work with http. I get a server not found exception...

Edit: require ssl is not checked in the iis manager

Edit 2:

this seems to work:

<rule name="Force HTTPS" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="off" />
    </conditions>
    <action 
        type="Redirect" 
        url="https://{HTTP_HOST}/{R:1}" 
        appendQueryString="true" 
        redirectType="Permanent" />
</rule>

but that does not work for: http://www.domain.com/app_themes/themeName/img.jpg

and for http://www.domain.com/urlrewritten (rewritten with maproutes in global.asax)

share|improve this question

migrated from stackoverflow.com Jun 16 '11 at 14:27

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer 1

up vote 0 down vote accepted
<rule name="Force HTTPS" stopProcessing="true">
    <match url="(.*)" />
    <conditions>
        <add input="{HTTPS}" pattern="off" ignoreCase="true"/>
    </conditions>
    <action 
        type="Redirect" 
        url="https://{HTTP_HOST}/{R:1}" 
        appendQueryString="true" 
        redirectType="Permanent" />
</rule>

works, also with url rewriting of mapping routes etc. tested in internet explorer, firefox and chrome :)

share|improve this answer
add comment

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.