Wednesday, September 24, 2008

Dynamic VirtualHost using mod_vhost_alias

I was looking into a solution for a customer and mod_vhost_alias came in handy.

Lets say you want to host blogs for several people and you want to host them on the following subdomain format: blogname.crazyblogs.com. Instead of having a separate virtual host for each one, you can do something like this:


UseCanonicalName Off
VirtualDocumentRoot /var/www/%0/htdocs
ServerName *.crazyblogs.com

Now, if you go to http://blog1.crazyblogs.com, it will look for a index file inside /var/www/blog1.crazyblogs.com/htdocs.

You can find further information on:

http://httpd.apache.org/docs/2.0/vhosts/mass.html#simple

http://httpd.apache.org/docs/2.0/mod/mod_vhost_alias.html

0 comments:

 
Template design by Amanda @ Blogger Buster