Reputation: 65
I am working on a webapplication that's running on a subdomain. In the code I used relative URL's all over the place. Nothing special, just the normal way to go.
I have just uploaded the site, but I can't find any file that I want to include. This, for example, is working now:
Site URL: sub.domain.com
CSS files are in: sub.domain.com/css/
Adding the following to the index.php **is working:**
<link rel="stylesheet" href="/css/styleSomething.css">
But including PHP files it the thing that is not working
Site URL: sub.domain.com
PHP Include files are in: sub.domain.com/inc/
Adding the following to the index.php is **not** working:
require_one(/inc/config.php)
If I change the URL's to start with a ./ or with no slash at all it will find the files for the homepage. But that's not going to work when the visitor navigets to a different page.
Am I missing some here of is this a problem with the hosting?
Upvotes: 1
Views: 936
Reputation: 2980
You can use the <base>
tag to set the root URL for your site: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/base
The following should work for your example:
<base href="http://www.blah.com/yadda1/yadda2">
<link rel="stylesheet" href="css/styleSomething.css">
This will reference the stylesheet at http://www.blah.com/yadda1/yadda2/css/styleSomething.css
.
If you are using PHP and using several URLs, place your base URL in a variable:
<base href="<?php echo $base_url; ?>">
Upvotes: 1
Reputation: 56
If I understand correctly, you have the pages under /rel1 under the root of the server. If so, try using /rel1/css/style.css.
Upvotes: 0