# Apache Vhosts - subdomaining

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 test.example.com.

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
DocumentRoot site_com/test

<Directory />
AllowOverride None
</Directory>

<Directory site_com/test>
AllowOverride All
Order allow,deny
allow from all
</Directory>


I successfully go to the correct index.html when I go to test.example.com.

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 test/index.html:

<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.

1
2022-07-25 20:44:28
Source Share