Image may be NSFW.
Clik here to view.
Currently I have several virtual hosts set up for individual subdomains. It would be a lot easier if I could tell Apache to automatically find the folder using a wildcard. For example, hello.domain.com
would use the /var/www/hello
directory as its DocumentRoot
.
I would like to be able to define exceptions however, such as if I wanted helloworld.domain.com
to point to /var/www/helloworld/public
instead.
I’ve looked around but all of the examples seem to be doing something different.
Image may be NSFW.
Clik here to view.
You’ll be able to configure that behavior with something along these lines:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName catchall.domain.com
ServerAlias *.domain.com
VirtualDocumentRoot /var/www/%1
</VirtualHost>
<VirtualHost *:80>
ServerName helloworld.domain.com
DocumentRoot /var/www/helloworld/public
</VirtualHost>
Check more discussion of this question.