Is editing "hosts" file in Windows necessary to host Apache Virtual Hosts?

I'm learning how to host websites on a small server at home. I followed some tutorials where they said you had to edit the "hosts" file (C:\Windows\System32\drivers\etc\hosts) and add the following:

After I would go to my "httpd-vhosts.conf" and enter something like this:

<VirtualHost *:80>
    DocumentRoot C:/Apache24/Websites/

Finally, I would go to Godaddy and have it point to my home IP.

Everything works great but just to do some testing I decided to remove the lines in the "hosts" folder leaving it empty. Restarted my apache service and the websites are still accessible.

So is modifying the hosts file even necessary?

Thanks for the help!

1 answer

  • answered 2018-11-08 23:58 Alvaro Bataller

    After doing some more research i found that adding it to the hosts file is not necessary. But if you do add it, when you access the website from the server machine, the request will go straight to the webserver instead of going to the internet and then back to the webserver.