: 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
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
ServerAdmin webmaster@example.com
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 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.
More posts by @Chiappetta492
1 Comments
Sorted by latest first Latest Oldest Best
You will need to load example.com/css/global.css as its for a different domain - the browser doesn't know about the directory structure on your server and cannot link the 2 sites together without a direct URL
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.