'/etc/hosts' ,http 链接正在重定向,但 https 链接没有重定向

6 iptables dns hosts

我编辑了 /etc/hosts 文件并输入了以下信息:

127.0.0.1    test.com  //working

127.0.0.1    https://test.com //not working . 
Run Code Online (Sandbox Code Playgroud)

从上面的信息来看,http://test.com正在重定向到 127.0.0.1,但https://test.com没有重定向到 127.0.0.1 。有什么办法可以做到吗?

cho*_*oba 10

/etc/hosts不关心协议,它处理主机名。此外,//不是/etc/hosts. 看

man hosts
Run Code Online (Sandbox Code Playgroud)

详情。

127.0.0.1 test.com
Run Code Online (Sandbox Code Playgroud)

应该足以重定向 http 和 https。您是否在本地主机上运行侦听 https 连接的服务?

  • 再说一遍:您的本地网络服务器是否配置为处理 https 请求? (3认同)