For example you have mydomain.com, my2nddomain.com.
mydomain.com should hit /var/www/folder1/index.html and my2nddomain.com should display the index.html of /var/www/folder2/index.php (Lets assume folder2 contains a php application like Joomla).
First of all make sure that both domains point to the IP of your server. Normally Apache2 is running under port 80 so you don't need to specify the port.
Now open for example with vim or nano the Apache2 according Apache config file:
nano /etc/apache2/sites-enabled/000-default
Here you should add two entries at the very end of the file:
<virtualhost *:80>
ServerName mydomain.com
ServerAlias *.mydomain.com
DocumentRoot "/var/www/folder2"
DirectoryIndex index.html
<directory "/var/www/folder">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
<virtualhost *:80>
ServerName my2nddomain.com
ServerAlias *.my2nddomain.com
DocumentRoot "/var/www/folder2"
DirectoryIndex index.php
<directory "/var/www/folder2">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
Now don't forget to restart the Apache2 server with:
/etc/init.d/apache2 restart
And you are good to go.
0 comments:
Post a Comment