I am trying to set up simple named based virtual hosting on my machine. The problem I am running into is I seem to be getting directed to whatever virtual host I have defined first in my vhosts.conf file. For example here are two entries :
- Code: Select all
<VirtualHost localhost:80>
ServerName localhost
DocumentRoot "C:/xampp/xampp/htdocs"
</VirtualHost>
<VirtualHost my.prj:80>
ServerName my.prj
DocumentRoot "C:/xampp/xampp/htdocs/myproject"
</VirtualHost>
Now, in this case if I navigate to http://localhost I end up in the proper place but if I navigate to http://my.prj I will go to C:/xampp/xampp/htdocs. If I switch the order of the hosts putting my.prj first I will get a similar result in that navigating to either addresses will send me to C:/xampp/xampp/htdocs/myproject
Here is the portion of my Windows hosts file I edited for this:
- Code: Select all
127.0.0.1 localhost
# ::1 localhost
127.0.0.1 my.prj
I am still learning about webserver admin so there is much I don't know. I set something like this up similarly on a Linux virtual machine and it seemed to work fine. Could anyone tell me what I am doing wrong here? Any advice is very much appreciated. Thank you very much for your time.