将主机添加到主机文件 [英] Adding a host to hosts file
问题描述
我正在尝试了解主机&阿帕奇一点.我想自己做的一件事是在/etc/hosts中添加一行,以便我可以在浏览器中访问localhost
I'm trying to learn about hosts & apache a little bit. One of the things I'm trying to do myself is to add a line to /etc/hosts so that way I can access localhost in the browser
当前,主机包含以下内容:
Currently, hosts contains this:
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
问题:1. :: 1和fe80 :: 1%lo8是什么意思?2.在通过在浏览器中键入"localhost"来访问127.0.0.1时,它们是否必不可少?3.我该怎么做才能创建指向127.0.0.1的附加链接,在浏览器中键入其他名称,例如"local",这样"localhost"和"local"都可以工作?
Questions: 1. What does the ::1, and fe80::1%lo8 mean? 2. Are they essential to the accessing of 127.0.0.1 via typing 'localhost' in your browser? 3. What would I do to create an additional link to 127.0.0.1 typing something else in the browser, like "local", so that way both "localhost" and "local" work?
推荐答案
克里斯蒂安(Kristian),我不确定这些符号的含义(例如::: 1),但是创建主机文件条目就像输入IP地址一样容易,并且然后是要匹配的域列表.
Kristian, I'm not sure what those symbols mean (::1 for example), but creating host file entries is as easy as typing an IP address and then the list of domains to match.
例如:
127.0.0.1 local localhost
会将本地"和本地主机"都匹配到127.0.0.1.您还可以执行以下操作:
will match both 'local' and 'localhost' to 127.0.0.1. You could have also done the following:
127.0.0.1 local
127.0.0.1 localhost
每行一个条目-如果要注释掉该行,请在每行的开头使用#".
One entry per line - use a '#' at the beginning of each line if you want to comment that line out.
这篇关于将主机添加到主机文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!