开发者

localhost problem on windows 7

I'm using Window开发者_开发技巧s 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?


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


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


Did you try: http://localhost:2710/default.aspx ?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜