'/etc/hosts' , http links are redirecting, but https links are not redirecting

/etc/hosts does not care about protocols, it handles host names. Moreover, // is not a comment character in /etc/hosts. See

man hosts

for details.

127.0.0.1 test.com

should be enough for redirecting both http and https. Do you run a service listening for https connections on your localhost?


I thought I was having a similar problem.

For anyone who makes the same silly mistake I did...

I was testing a new webserver by rerouting the requests to a different IP by /etc/hosts.

I did tail -f access_log on my web server and saw all my test requests, except the https ones. I spent a few minutes trying to figure that out.

Finally, I realized that I log SSL requests to a different file. Those log entries were working just fine, in access_ssl_log. Doh!