3

Using IIS in Windows server 2012 R2.

I have a website which can be reached at url.com and www.url.com. I have https://url.com set up using https://letsencrypt.org/.

I want to redirect all incomming requests to https://url.com/{path} That is, it needs to handle

I added this rewrite rule to the webconfig.

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

and this works for any url such as http://url.com/some but if i type in https://www.url.com/s I get an error stating the connection is not secure. This is also the case if I try http://www.url.com

How do i make this work?

3

You can't avoid requests reaching www.example.com and not getting the error, because redirections happen "after" the SSL has been negotiated, and the client is requesting a name for which you don't have a certificate.

Letsencrypt allows you perfectly to have the same certificate with several names. So you will have to do that to avoid client browsers complaing or mismatched name in certificate.

1
  • alright, just have to figure out how to configure lets encrypt for this.. they dont seem overly windows friendly.. or rather the tools that exist arent that well built yet (using github.com/Lone-Coder/letsencrypt-win-simple atm). – JensB Oct 20 '16 at 10:47
1

check subject name and subject alternative name in the SSL certificate you are using .

seems it is valid only for url.com not for www.url.com

you need to mention this while requesting certificate

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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