On my local dev server, I set up test sites with the domain like this projectName.dev
Using the setting below in my Apache config file...
NameVirtualHost *:80
<VirtualHost *:80>
VirtualDocumentRoot E:/Server/htdocs/projects/%1/www
ServerAlias *.dev
</VirtualHost>
This allows me to access projectName.dev
in the browser and it will load the files from E:/Server/htdocs/projects/projectName/www/
I would like to modify this so that I can also access the same folders if I use the subdomain www
so in my example projectName.dev
and www.projectName.dev
would load the same files.
Can someone help me to do this? I don't understand the documentation very well
You could try the following
You can use %-2 to always get the "project" name. %-2 give you the second part of the url from the end. For e.g., if url would be http://project1.dev/ then the docroot would be E:/Server/htdocs/projects/project1/www
The ALex_hha reply is correct, the problem is the %1 in the VirtualDocumentRoot. that is replaced by the hostname used. using both multiple wildcard variants and VirtualDocumentRoot is always tricky.
You have 2 solutions:
projectName.dev
.If you have many projects you would need to create a virtualhost config for each project, but just for one is a good workaround.
create 2 configs:
the %2+ says that you want the second and forward part of the hostname received. Check the mod_vhost help page for more info
You are not using a unix, but on unix you could also do a symbolic link from the www names to the project names:
This way both the projectname and www.projectname point to the same place