Configure main domain and sub domain with diffrent resourcs in apache server

Posted by Ritesh Patadiya on Stack Overflow See other posts from Stack Overflow or by Ritesh Patadiya
Published on 2012-09-06T17:21:55Z Indexed on 2012/09/27 3:37 UTC
Read the original article Hit count: 184

Filed under:
|

I have an issue to creating a sub domain in apache server. Normally we can do that by following way.

<VirtualHost *:80>
  ServerName www.maindomain.com
  ServerAlias *.maindomain.com
  DocumentRoot "/home/abc/xyz"
  <Directory "/home/abc/xyz">
    AllowOverride All
    Allow from All
  </Directory>
</VirtualHost>

In above example both main and sub domain share same Directory.

But my requirement is main domain have its own resource and rest of sub domains have other resource.

I want to do something like this.

<VirtualHost *:80>
    ServerName www.maindomain.com
    DocumentRoot "/home/abc/xyz"
    <Directory "/home/abc/xyz">
        AllowOverride All
        Allow from All
    </Directory>
</VirtualHost>

<VirtualHost *:80>
    ServerName xyz.maindomain.com
    ServerAlias *.maindomain.com
    DocumentRoot "/home/ghi/pqr"
    <Directory "/home/ghi/pqr">
        AllowOverride All
        Allow from All
    </Directory>
</VirtualHost>

Above thing didn't work for me

© Stack Overflow or respective owner

Related posts about apache

Related posts about subdomains