Redirect all site traffic from https://example.co.uk to https://www.example.co.uk

Hi Guys,

I've got an issue where I need to redirect all site traffic to the subdomain www. This is because the SSL certificate uses a SAN which is specifically http://www.example.co.uk. If a user goes to https://example.co.uk they get an SSL warning because the SAN doesn't match that URL. I can't change that unfortunately as that's what the customer has bought. I also have to redirect all traffic to HTTPS.

I have a redirect working for all HTTP traffic using the following in apache in the website conf file (using Mod Rewrite)

RewriteEngine On
RewriteCond %{HTTPS} off [OR]
RewriteCond %{HTTP_HOST} ^example\.co.uk$ [NC]
RewriteRule (.*) https://www.example.co.uk%{REQUEST_URI} [R,L]

This works fine until a user goes to https://example.co.uk when it doesn't redirect.

I was wondering if I'd botched the rules somehow? If not, is what I'm trying to do possible before the user gets an SSL error or would I have to find some way of redirecting before the users hits the server and gets the SSL certificate? Can Linodes DNS tools do this somehow?

Ta!

2 Replies

SSL/TLS authentication happens before the redirect can ever take place. The only thing you can do is re-issue the certificate to cover both example.co.uk and www.example.co.uk. Most SSL providers will do a re-issue for www/bare domain issues, if you can convince the customer to go back to their provider — otherwise, you might consider trying out Let's Encrypt.

That's what I was assuming. I was wondering if there was anything I could do before it hit the SSL authentication.

I can get them to remake the certificate (which is really easy actually) but it will mean them having to spend more money on certificates down the line which they don't want to do.

Let's Encrypt looks interesting! I haven't heard of them, I wonder if there are any known issues with browsers using certificates from there? EDIT: As soon as I posted that I found this…

https://community.letsencrypt.org/t/whi … crypt/4394">https://community.letsencrypt.org/t/which-browsers-and-operating-systems-support-lets-encrypt/4394

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct