Configure main domain and sub domain with diffrent resourcs in apache server
- by Ritesh Patadiya
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