Page 1 of 1

virtual hosts

PostPosted: 31. July 2018 12:43
by azimut
Hi everyone,
I have problem with configuration virtual hosts. I have at the htdocs 2 folders - t and t2. I want to use url t.locahost and t2.locahost to open different projects. My httpd-vhosts.conf looks:
Code: Select all
NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/t2"
ServerName t2.localhost
<Directory "c:/xampp/htdocs/t2">
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "c:/xampp/htdocs/t"
ServerName t.localhost
<Directory "c:/xampp/htdocs/t">
</Directory>
</VirtualHost>


and my host file looks:
Code: Select all
# localhost name resolution is handled within DNS itself.
#   127.0.0.1       test
#   ::1             localhost
#   127.0.0.1      test.locahost
   127.0.0.1      t.locahost
   127.0.0.1      t2.locahost

I commented documentroot at httpd.conf.
Can you help me with this issue? Xampp gives me only t2.locahost.
Thank you

Re: virtual hosts

PostPosted: 31. July 2018 13:53
by Altrea
Remove the line NameVirtualHost *:80, this is no longer needed
Fix your host names in your hosts file. You are writing locahost instead of localhost
And don't comment the DocumentRoot in your httpd.conf. This is not needed.

Re: virtual hosts

PostPosted: 31. July 2018 14:12
by azimut
Hi, thank you for your advice. It was very helpful.