Page 1 of 1

Virtualhost not working

PostPosted: 13. December 2012 22:35
by mths
When I set up a virtual host is keeps redirecting me to the same as localhost (/opt/lampp/htdocs/). Why? My hosts looks like this:
Code: Select all
127.0.0.1   localhost
127.0.0.1   ym.local
127.0.1.1   W520

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

En my /opt/lampp/etc/extra/httpd-vhosts.conf looks like so:
Code: Select all
NameVirtualHost *:80
<VirtualHost *:80>
   DocumentRoot "/opt/lampp/htdocs/"
   ServerName localhost
   ServerAlias localhost
</VirtualHost>
<VirtualHost *:80>
    DocumentRoot "/opt/lampp/htdocs/m/ym7up/"
    ServerName ym.local
    ServerAlias ym.local
    <Directory "/opt/lampp/htdocs/m/ym7up/">
        Options Indexes FollowSymLinks Includes ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
</VirtualHost>

The 'm' in htdocs/m/ym7up is a symlink. However, I just get routed to 'localhost' or /xampp/ so it seems to miss the whole thing.
This problem seems to pop up on several forums but I have not found one threat that ended in a solution (for me). Anyone a clue? What makes your virtual hosts work?

Re: Virtualhost not working

PostPosted: 14. December 2012 00:20
by JonB
DocumentRoot "/opt/lampp/htdocs/m/ym7up/"

It is a poor practice to nest a new virtualhost inside another DocumentRoot.

A good place for a new DocumentRoot would be at the /opt/lampp level

i.e:
DocumentRoot "/opt/lampp/m/ym7up/"

Good Luck