Ubuntu 18.04 Apache2 Virtual Host is showing main website

I am attempting to make a subdomain for my website and I have created a virtual host, when I access the website subdomain.mydomain.com It show the same page as mydomain.com. Below is my virtual host.

<VirtualHost subdomain.mydomain.com:80>
DocumentRoot /var/www/subdomain
ServerName subdomain.mydomain.com
ServerAlias www.subdomain.mydomain.com
<Directory "/var/www/subdomain">

This is placed in a separate virtual host file I have read a few other topics on here that say place it in the default host file, after trying that I am still having the same issue. Any help would be greatly appreciated.

Answers 1

  • After doing some more research I have found out that my virtual host was setup wrong below is the virtual host that worked for me.

    <VirtualHost *:80>
            ServerAdmin me@mydomain.com
            #referring the user to the recipes application
            DocumentRoot /var/www/subdomain
            ServerName subdomain.mydomain.com
            <Directory /var/www/subdomain>
                    Options Indexes FollowSymLinks MultiViews
                    AllowOverride All
                    Order allow,deny
                    allow from all
                    # Uncomment this directive is you want to see apache2's
                    # default start page (in /apache2-default) when you go to /
                    #RedirectMatch ^/$ /apache2-default/
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined

Related Questions