Why does 301 redirect work for http but not for https?
- by Tom G
Through my domain registrar I have set up a domain, essayme.co.uk, to automatically forward to https://google.com.
If I go to http://essayme.co.uk it works as expected and redirects me to https://google.com.
$curl -i http://essayme.co.uk
HTTP/1.1 301 Moved Permanently
Cache-Control: max-age=900
Content-Type: text/html
Location: https://google.com
Server: Microsoft-IIS/7.5
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Date: Sat, 07 Jun 2014 11:14:16 GMT
Content-Length: 0
Age: 0
Connection: keep-alive
However, if I go to https://essayme.co.uk it just freezes and times out.
$curl -i https://essayme.co.uk
curl: (7) Failed connect to essayme.co.uk:443; Operation timed out
What is happening in the second case?
(and, if possible, how can I get the redirect to work for https?)
Problem background/clarification:
I don't have an SSL certificate for the essayme.co.uk domain above, but I do for my live domain (let's call it mywebsite.com), and I was seeing the exact same problem on this domain (hence why I'm trying to debug the problem). Unfortunately I can't experiment with the live domain (as it's live) and I would like to avoid having to buy a second certificate for essayme.co.uk just for debugging (unless absolutely necessary).
The problem I was seeing:
my live domain, mywebsite.com (not its real name), has a valid SSL certificate.
Visiting https://www.mywebsite.com displayed the webpage as expected.
I had set up forwarding (like in the question above) from the naked domain (mywebsite.com) to https://www.mywebsite.com)
Visiting http://mywebsite.com redirected to https://www.mywebsite.com as expected.
However, visiting https://mywebsite.com would freeze and time out (as in the question above).
I also tried forwarding it to http://www.otherwebsite.com as an experiment (i.e. forwarding to another site that does not use SSL), but the result was the same:
Visiting http://mywebsite.com redirected to http://www.otherwebsite.com as expected.
Visiting https://mywebsite.com would freeze and time out again.
So I set up essayme.co.uk as an experiment to try and understand why it doesn't work.