The subdomain is working and connecting to my website but linking to the root and no the folder I thought I was linking to.
<VirtualHost *:80> DocumentRoot /var/www/html/backend ServerName www.teach.joshhornby.co.uk <Directory /var/www/html/backend> Allow from all Options +Indexes </Directory> </VirtualHost>
I have checked the file structure and the file is located here
OK, so you have two problems here.
The first problem is that the hostname you referenced in your
ServerName doesn’t exist in the DNS. A different hostname does exist, though…
$ host joshhornby.co.uk joshhornby.co.uk has address 18.104.22.168 joshhornby.co.uk has address 22.214.171.124 $ host teach.joshhornby.co.uk teach.joshhornby.co.uk has address 126.96.36.199 $ host www.teach.joshhornby.co.uk Host www.teach.joshhornby.co.uk not found: 3(NXDOMAIN)
The second problem is that you specified a different hostname in the
ServerName field than you are using in your web browser. While Apache is expecting
www.teach.joshhornby.co.uk, you are using
teach.joshhornby.co.uk. Since Apache doesn’t know what to do with those, it punts, and you get your default virtual host.
To resolve the issue:
Add a DNS record for
ServerAlias teach.joshhornby.co.ukto your virtual host.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.