user2030809 user2030809 - 2 months ago 20
Apache Configuration Question

xampp virtual host - always loading htdocs

I am trying to create a virtual host on my localhost (XAMPP). Tried every combination out there, but I always get htdocs loaded instead of the specific folder

Here is the

hosts
file:

127.0.0.1 localhost
::1 localhost
127.0.0.1 devsnappy


Here is
httpd-vhosts.conf
:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot E:/xampp/htdocs/snappy/public
ServerName devsnappy
<Directory "E:/xampp/htdocs/snappy/public">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>


Any suggestions?

Answer

Here is a guide to add vhost to xampp

Seems that you miss something with the hosts file.

For example, say you had another Web site for ClientB. You’d add 127.0.0.1 clientB.local >in the hosts file and the C:\xampp\apache\conf\extra\httpd-vhosts.conf would look like this:

NameVirtualHost *
  <VirtualHost *>
    DocumentRoot "C:\xampp\htdocs"
    ServerName localhost
  </VirtualHost>
  <VirtualHost *>
    DocumentRoot "C:\Documents and Settings\Me\My Documents\clientA\website"
    ServerName clientA.local
  <Directory "C:\Documents and Settings\Me\My Documents\clientA\website">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>
<VirtualHost *>
    DocumentRoot "C:\Documents and Settings\Me\My Documents\clientB\website"
    ServerName clientB.local
  <Directory "C:\Documents and Settings\Me\My Documents\clientB\website">
    Order allow,deny
    Allow from all
  </Directory>
</VirtualHost>

And restart httpd

Comments