问题描述
安装TeamViewer后,我把wampserver的端口改成了8080,所以地址是http://localhost:8080.
After installing TeamViewer, I have changed the wampserver port to 8080, so the address is http://localhost:8080.
对于位于 C:\WINDOWS\system32\drivers\etc\ 的主机文件,我也做了如下更改
For the host file located at C:\WINDOWS\system32\drivers\etc\, I have also made the change as below
之前127.0.0.1 www.example.com
之后127.0.0.1:8080 www.example.com
当我访问 www.example.com 时,它没有重定向到我的 wampserver,我该如何解决?
When I access www.example.com, it doesn't redirect to my wampserver, how can I fix it?
推荐答案
hosts
文件仅用于主机名解析(在 Windows 以及类 Unix 系统上).您不能将端口号放在那里,并且无法使用通用的操作系统级配置来做您想做的事情 - 浏览器选择要选择的端口.
The hosts
file is for host name resolution only (on Windows as well as on Unix-like systems). You cannot put port numbers in there, and there is no way to do what you want with generic OS-level configuration - the browser is what selects the port to choose.
所以使用书签或类似的东西.
(某些防火墙/路由软件可能允许出站端口重定向,但这听起来并不是一个吸引人的选项.)
So use bookmarks or something like that.
(Some firewall/routing software might allow outbound port redirection, but that doesn't really sound like an appealing option for this.)
这篇关于在 Windows 主机文件中使用端口号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!