'/etc/hosts' , http links are redirecting, but https links are not redirecting
Solution 1
/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?
Solution 2
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!
Related videos on Youtube
Admin
Updated on September 18, 2022Comments
-
Admin over 1 year
I edited /etc/hosts file and entered below information :
127.0.0.1 test.com //working 127.0.0.1 https://test.com //not working .
from the above info, http://test.com is redirecting to 127.0.0.1, but https://test.com is not redirecting to 127.0.0.1 . Is there any way I can do that?
-
sensorario almost 11 yearsI've got the same issue. Have you solved?
-
-
Sudipta Basak almost 12 yearsleave those commnents, i just entered them here . My use case is,in my website some parts of the code can be tested only with the domain name, and my website uses https . So, if it is just http, i can test locally with the domain name . But as it is https, I am unable to test locally .
-
Sudipta Basak almost 12 yearsOnce more: Is your local webserver configured to handle https requests?