I'm using Apache on Windows and since I have few sites to manage I was interested in creating subdomains for localhost. For example using "http://ga.localhost" is easier to manage than "http://localhost/ga/".

I've tried editing apache's httpd.conf by adding something like:

NameVirtualHost *

<VirtualHost *>
ServerAdmin email@email.com
DocumentRoot D:/webroot/site1/
ServerName s1.localhost
ErrorLog logs/s1.localhost-error_log
CustomLog logs/s1.localhost-access_log common
</VirtualHost>

<VirtualHost *>
ServerAdmin email@email.com
DocumentRoot D:/webroot/site2/
ServerName s2.localhost
ErrorLog logs/s2.localhost-error_log
CustomLog logs/s2.localhost-access_log common
</VirtualHost>

But this doesn't work and I don't know why. There is no chance to access to s1.localhost by typing "http://s1.localhost/" into a browser, but when I type "http://localhost/" it loads content of /site1...

If someone has idea what is wrong about this method or if there is any other method for doing this please help.

Thanks in advance.

    read up on DNS severs. make sure you understand top level domians (TLD) and sub-domains.

    without DNS, s1.localhost will not resolve to anywhere!

      Write a Reply...