apache subdomain virtual host code example
Example 1: virtual host apache
<VirtualHost *:80>
ServerName domain1.com
ServerAlias www.domain1.com
ServerAdmin [email protected]
DirectoryIndex index.html
DocumentRoot /home/demo/public_html/domain1.com/public
LogLevel warn
ErrorLog /var/log/apache2/error-mydomainname.com.log
CustomLog /var/log/apache2/access-mydomainname.com.log combined
</VirtualHost>
sudo a2ensite domain1.com
sudo /etc/init.d/apache2 reload
Example 2: APACHE MULTIPLE HOstnames
Listen 80
<VirtualHost *:80>
DocumentRoot "/www/example1"
ServerName www.example.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/www/example2"
ServerName www.example.org
</VirtualHost>