Monday, March 16, 2009

apache httpd configuration for a domain and its subdomain

I basically wanted to serve different pages from xyz.in and m.xyz.in with separate logs for both, Here is what I had to put at the end of httpd.conf

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /var/www/html/pcmm/
ServerName www.xyz.in
CustomLog /var/log/httpd/access_log combined
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html/mobilemm/
ServerName m.xyz.in
CustomLog /var/log/httpd/m_access_log combined
</VirtualHost>
First virtual host becomes the default, so if a request comes for xyz.in or www.xyz.in or any other subdomain(except m.xyz.in) then its served from the first vhost or else from the later one, we can put as many vhosts as we wish. More information is available here .

No comments:

Post a Comment