Page 1 of 1
Wildcard Virtual Host in Apache2
Posted: Fri Sep 19, 2008 6:25 am
by panic!
hi guys,
What I'd like to do, is have a wildcard catch-all subdomain that will use a directory as it's DocumentRoot based on the subdomain at present I have:
Code: Select all
<VirtualHost *:80>
DocumentRoot /var/www/vhosts/cats/
ServerName cats.darwin
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/vhosts/dogs/
ServerName dogs.darwin
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /var/www/vhosts/mice/
ServerName mice.darwin
</VirtualHost>
what I'd like to do is have something like
Code: Select all
<VirtualHost *:80>
DocumentRoot /var/www/vhosts/this-bit-be-matched-to-the-sub-domain/
ServerName *.darwin
</VirtualHost>
Are there any smarty pants geniuses that know how I could do this?
Thank you all.
Re: Wildcard Virtual Host in Apache2
Posted: Fri Sep 19, 2008 8:20 am
by Maugrim_The_Reaper
Look up the VirtualDocumentRoot directive along with the mod_vhost_alias module for Apache 2.2. I'm not going to elaborate since I'm 99% certain it's explained in the Apache manual as mass virtual hosting.
If you can't get it to work using the manual and a google search then someone will be willing to dig deeper into the mechanics, but please try it yourself first

.
Re: Wildcard Virtual Host in Apache2
Posted: Fri Sep 19, 2008 9:21 am
by panic!
ok sweet thank you figured that out now
now I have the following which works perfectly. but the .htaccess files within each vhost are breaking and giving 'Internal Server Error'
My new, working conf
Code: Select all
NameVirtualHost xxx.darwin.juretic:80
<VirtualHost xxx.darwin.juretic:80>
ServerName xxx.subdomain.domain.com
ServerAlias *.darwin.juretic
UseCanonicalName Off
DocumentRoot "/var/www/vhosts/"
VirtualDocumentRoot /var/www/vhosts/%1
<Directory "var/www/vhosts/">
Options +FollowSymLinks
Options Includes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
my now breaking .htaccess
Code: Select all
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.+)$ index.php [L]
RewriteRule ^()$ index.php [L]
options -indexes
I'm guessing I need to some how prefix the Conds and Rules with the VirtualDocumentRoot's
I've tried messing around with a few things and I can't figure

Re: Wildcard Virtual Host in Apache2
Posted: Fri Sep 19, 2008 9:25 am
by panic!
FIXED:
Code: Select all
# RewriteEngine On
#
#
# RewriteCond %{REQUEST_FILENAME} !-f
# RewriteCond %{REQUEST_FILENAME} !-d
#
# RewriteRule ^(.+)$ /index.php [L]
# RewriteRule ^()$ /index.php [L]
#
# options -indexes
added / to the start of /index.php
rad!
Re: Wildcard Virtual Host in Apache2
Posted: Fri Sep 19, 2008 9:44 am
by jayshields
Have you commented out those lines or was that a pasting error? I'm pretty sure it's the latter but I'm just clearing things up

Re: Wildcard Virtual Host in Apache2
Posted: Fri Sep 19, 2008 9:51 am
by Maugrim_The_Reaper
Bow down and worship me

.
Re: Wildcard Virtual Host in Apache2
Posted: Fri Sep 19, 2008 11:57 am
by panic!
pasting error TEEEHEEEEEEE.