Link multiple ServerAlias to one DocumentRoot

For all those who wondered, if there is a simple way to link multiple sites to one document root in an Apache config, here is an answer:

YES, it is possible.


    ServerAdmin webmaster@localhost
    ServerName example.com
    ServerAlias subdomain1.example.com subdomain2.example.com
    DocumentRoot /var/www/website_source_code/

You can give multiple values to the ServerAlias parameter in you site configuration.

On an Ubuntu machine running an Apache web server, you can find your configurations under /etc/apache2/sites-available.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close Menu