I am a little new to the apache vhosts configuration and for educational purposes I wish to set up a domain and a subdomain.
The domain is already set up under the name
example.com. Now I want to create a subdomain
Consider the following (desired) directory structure:
- site_com - test - index.html - css - gobal.css - index.html
I have managed to do this by doing:
<virtualhost *:80> ServerName test.example.com ServerAdmin firstname.lastname@example.org DocumentRoot site_com/test <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory site_com/test> Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory>
I successfully go to the correct index.html when I go to
Now consider that index.html is a very simple page that contains a relative path to load a css file from the
site_com/css directory. by using the following code in
<link href="../css/global.css" rel="stylesheet" type="text/css"/>
However the CSS does not load. The reason is a 404 response. I have verified that the actual directory structure is correct and I have no idea why this behaves like that. I have used webhosts before and there a subdomain is also just a folder in your top domain but everything works perfectly. The stack software I use is called ZPanel.