Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question
1  
Did you correctly restart httpd ? –  p1rox Jul 16 at 9:24

1 Answer

up vote 1 down vote accepted

Here is a guide to add vhost toi 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

share|improve this answer
 
I don't think this has anything to do with the hosts file. A better guess would be that he simply forgot to restart the apache server after modifying httdp-vhosts.conf. –  Krister Andersson Jul 16 at 9:28
 
i copy pasted the example from the guide ... changed the paths ... restarted and worked ... then changed back to my custom vhost name ... restarted and worked ... i do not exactly what the pb was (this guide was the first one i did) but if someone has the same pb as me it might help to follow this answer ... thanks all –  user2030809 Jul 16 at 9:46
 
+1 - Sorry, my mistake I though you were talking about the /etc/hosts file. –  Krister Andersson Jul 16 at 10:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.