Results 1 to 2 of 2
Jan 25, 2014, 10:19 #1
- Join Date
- Mar 2006
- Akron, OH
- 0 Post(s)
- 0 Thread(s)
VirtualDocumentRoot Setup For Local Development
I'm trying to learn about setting up httpd.conf and httpd-vhosts.conf files. I would like to have a local setup, using Wampserver on Windows 7, so that I can add a new project just by adding a new directory and a quick edit to the hosts file. I would like for it to work at least for the following general domain formats: domain.com, www.domain.com, sub.domain.com, and www.sub.domain.com.
The following is what I have so far. It seems to work, but I'm just thinking there is likely a better, possibly more succinct way:
NameVirtualHost *:80 <Directory "C:/wamp/www/%0/public_HTML"> Options Indexes FollowSymLinks Includes AllowOverride All Order allow,deny Allow from all </Directory> <VirtualHost *:80> VirtualDocumentRoot "C:/wamp/www/%0/public_HTML" </VirtualHost> <VirtualHost *:80> ServerAlias www.*.*.com VirtualDocumentRoot "C:/wamp/www/%3+/public_HTML/%2" </VirtualHost> <VirtualHost *:80> ServerAlias www.*.com VirtualDocumentRoot "C:/wamp/www/%2+/public_HTML" </VirtualHost> <VirtualHost *:80> ServerAlias *.*.com VirtualDocumentRoot "C:/wamp/www/%2+/public_HTML/%1" </VirtualHost>
This works, but if I change the order of the VirtualHosts in any way, it causes a 404 error for at least one of the domain formats listed above. I was wondering if anyone could explain to me why that is? And also, if someone has a suggestion for a better way to approach all of this, I'd love to hear it.
Thanks!Thank you, Chuck Norris.
Jan 25, 2014, 23:57 #2
- Join Date
- Feb 2002
- 19 Post(s)
- 2 Thread(s)
You've not told your server anything about the virtual domains you want to establish!
Okay, that's probably not your fault as WAMP may not have given you Apache's httpd-vhosts.conf file with the comments to help you. So, using my test server as an example ...
<VirtualHost 127.0.0.1:80> ServerName dk DocumentRoot W:/dk ServerPath W:/dk </VirtualHost>
<VirtualHost 127.0.0.1:80> ServerName domain DocumentRoot D:/abc ServerPath D:/abc </VirtualHost> <VirtualHost 127.0.0.1:80> ServerName sub.domain DocumentRoot D:/xyz ServerPath D:/xyz </VirtualHost>
Don't forget that you will also need a pair of lines in the hosts file like
127.0.0.1 domain # and 127.0.0.1 sub.domain