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.

I am trying to do something extremely straightforward. I just need to force SSL and I am trying to use the URl Rewrite plugin. I am getting no results when I put the following rule into my conf.

      <rewrite>

        <rules>

           <rule name="Redirect to https" stopProcessing="true">
           <match url="(.*)[^/])$" />
            <conditions>
                    <add input="{SERVER_PORT}" pattern="443" negate="true" />
            </conditions>
             <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" />
          </rule>
        </rules>

    </rewrite>

Any thoughts on why this isn't catching?

share|improve this question
    
This pattern is wrong: (.*)[^/])$ -- extra closing ) (remove one of them) -- possibly that is the reason? BTW -- better check {HTTPS} = off instead of {SERVER_PORT} != 443, as you can easily run ssl on another (non-standard) port. –  LazyOne Apr 11 '12 at 20:40
    
Thanks, I made that change but I am still not getting a redirect. I just get HTTP Error 404. The requested resource is not found. –  Nolan Berry Apr 11 '12 at 20:50

1 Answer 1

This is the rule that I have on a fully working site -- works absolutely fine. As you can see it is very close to what you have.

    <rewrite>
        <rules>
            <clear />
            <rule name="Redirect to https" stopProcessing="true">
                <match url=".*" />
                <conditions>
                    <add input="{HTTPS}" pattern="off" />
                </conditions>
                <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" />
            </rule>
        </rules>
    </rewrite>

If it does not work for you -- then you have too look for something else (SSL is not configured at all/wrongly configured SSL etc). Dig into error details -- it should say:

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.