Mobile app version of vmapp.org
Login or Join
Reiling115

: Why does 301 redirect timeout with HTTPS even though it works with HTTP? Through my domain registrar I have set up a domain, essayme.co.uk, to automatically forward to https://google.com. If I

@Reiling115

Posted in: #Dns #Https #Redirects

Through my domain registrar I have set up a domain, essayme.co.uk, to automatically forward to google.com.
If I go to essayme.co.uk it works as expected and redirects me to google.com.
$curl -i essayme.co.uk HTTP/1.1 301 Moved Permanently
Cache-Control: max-age=900
Content-Type: text/html
Location: 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 essayme.co.uk it just freezes and times out.

$curl -i 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 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 www.mywebsite.com) Visiting mywebsite.com redirected to www.mywebsite.com as expected.
However, visiting mywebsite.com would freeze and time out (as in the question above).


I also tried forwarding it to www.otherwebsite.com as an experiment (i.e. forwarding to another site that does not use SSL), but the result was the same:


Visiting mywebsite.com redirected to www.otherwebsite.com as expected.
Visiting 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.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Reiling115

2 Comments

Sorted by latest first Latest Oldest Best

 

@Candy875

I have used this code and it's resolving perfectly. Please check whether it's correct or not.

RewriteEngine On
RewriteBase / #Redirect non-www to www

RewriteCond %{HTTP_HOST} !^www.
RewriteRule ^(.*)$ www.%{HTTP_HOST}/ [R=301,L]

# Redirect to HTTPS
RewriteCond %{HTTPS} off
RewriteRule (.*) www.pnrstatusbuzz.in/ %{REQUEST_URI}

10% popularity Vote Up Vote Down


 

@Yeniel560

example.com/something and example.com/something are distinct URIs. Therefore, they identify different resources. While it's common practice to serve the same page on a web site for both and , it's by no means mandatory.

(In fact, I generally think it's better to return 404 on URIs that would be sensitive content on during development time, instead of using automatic redirections from to like some do, so as to be able to detect bad links and insecure initial connections, but that's a different problem.)

There is no reason why a redirection from example.com/ to something-else.example/ should also apply to example.com/. They're distinct URIs as far as your browser is concerned.

Since you're saying that there's no HTTPS server listening on port 443 of the domain from which you're trying to make this redirection, nothing is going to happen.

In addition, if you wanted there to be a redirection (or any other form of response) from that HTTPS server, you'd also need a valid certificate for it. (Many CAs will issue certs with two Subject Alternative Names, for example.com and example.com, but not all do it for free.)

As a side-node, when you're experimenting with redirections, I'd suggest using 302 instead of 301, since 301 will often be cached by your browser, so the changes you've made in the configuration might not always be applied in your browser.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme