Windows 7 上的本地主机问题

发布于 2024-08-08 02:48:36 字数 360 浏览 2 评论 0原文

我使用的是 Windows 7 Pro,想要在本地运行我的 Web 项目,但 URL www.localhost.com 不起作用。

如果使用 http://127.0.0.1:2710/default.aspx 它可以工作。我检查了 C:\Windows\System32\Drivers\Etc\hosts 文件夹中的主机文件。如果我删除行:

#   127.0.0.1       localhost
#   ::1             localhost

没有任何变化。如何让 www.localhost.com 在我的机器上运行?

I'm using Windows 7 Pro and want to run my web project locally, but the url www.localhost.com does not work.

If use http://127.0.0.1:2710/default.aspx it works. I checked host file which in the C:\Windows\System32\Drivers\Etc\hosts folder. If I delete the rows:

#   127.0.0.1       localhost
#   ::1             localhost

Nothing changes. How can I make www.localhost.com work on my machine?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

神经暖 2024-08-15 02:48:36

希望我正确理解你的问题。您想使用 www.localhost.com 访问本地站点

只需编辑主机文件并添加以下行

127.0.0.1 www.localhost.com

我检查了我的 Windows 7 主机文件,它有以下行

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

以上行是注释和删除这些线没有做任何事情。

注意:如果保存主机文件时出现“访问被拒绝”,请以管理员身份打开记事本,然后编辑主机文件并保存。应该有效

Hope I understand your question correct. You want to acces your local site using www.localhost.com

Just edit the hosts file and add the following lines

127.0.0.1 www.localhost.com

I checked my Windows 7 hosts file and it has the following lines

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

Above lines are comments and deleting those lines does not do anything.

Note: If you get "Access denied" when you save the hosts file then open notepad as Administrator and then edit hosts file and save it. It should work

伪心 2024-08-15 02:48:36

编辑:您删除的行只是注释,所以这并不重要。

您是否尝试输入您的网址,就像 localhost
或者作为 http://localhost:2710/default.aspx?< br>
后者可能是必要的,因为 2710 是端口号,如果没有它,将默认为端口 80,该端口可能没有任何监听。


更新:它实际上可能是一个 IPv6 的东西,所以在你的主机文件中尝试使用这一行:

127.0.0.1       localhost

你不应该在该行的开头有一个 # ,将禁用该行。

(您可能也需要重新启动)。

您还可以尝试 ping localhost(只需在命令提示符窗口中输入 ping localhost)并检查是否收到来自 127.0.0.1 的回复

EDIT: The rows you deleted were just comments, so that doesn't matter.

Were you trying to enter your url just as localhost
or as http://localhost:2710/default.aspx?
The latter is probably necessary, as the 2710 is the port number, and without it will default to port 80, which probably doesn't have anything listening on it.


UPDATE: It might actually be an IPv6 thing, so try it with just this line in your hosts file:

127.0.0.1       localhost

You should not have a # at the beginning of the line, that will disable that line.

(You might need to reboot too).

You could also try pinging localhost (just type ping localhost in a command prompt window) and check that you get a reply from 127.0.0.1

久光 2024-08-15 02:48:36

好的,简单地说,您的 Web 项目将在 http://localhost:2710/default.aspx 上运行,一旦您将删除的这些行放回主机文件中(更多信息请参见此处 )。要删除端口号,您需要重新配置您的网络服务器

现在,如果您想获得一个,那完全是另一回事......然后,您需要获得一个注册商并使用 DNS 来将其映射到您。如果您希望其他人能够使用 www.site.com 等网站访问您的网站,则可以这样做。

Okay, simply put, your web project will run on http://localhost:2710/default.aspx, once you put those lines you removed back into the hosts file (More on it here). To get to remove the port number, you need to reconfigure your web server.

Now, if you want to get a domain, that's a different thing altogether... then, you need to get a registrar and use DNS to get it to map to you. You would do this if you wanted other people to be able to use something like www.site.com to get to your site.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文