Alright so im done doing pages with frames, and know i splitted up my design to top.php and bottom.php. In top.php it’s linking to style.css and ajax_framework.js and such.. Now this works great until i tried to include top.php & bottom.php in videos/index.php (another dirr), i did like this:
include "../top.php";
<-- and the originally index.php -->
include "../bottom.php";
Now when i enter the site, it wont load style.css, probably because it thinks that style.css needs to be in videos/ directory, same goes with ajax_framework.js that are both files are on the parent ../ directory.
Now what do i do? Some method or technique to solve this in a good way? So i dont have to copy style.css and ajax_framework.js into every directory i have, because then later if i want to change something i would need to change in all directories, which would be my last thing i want to do.. hope you got some nice techniques thank you
You have at least three options:
Make all your resources URL absolute URL. For instance, change
<script type="test/javascript" src="scripts/foo.js">to<script type="text/javascript" src="/scripts/foo.js">. If you can do it, it’s by far the less intrusive solution.Set a
BASEDIRconstant before you includetop.phpand make every resource path relative to it:Add a
<base>HTML tag in your<head>(this one sucks, don’t do it):Its sucks because even anchors will be relative to it. So if you have a link like
<a href="#foo">on the pageqaz.php, with the<base href="/bar">, the link will point to/bar#fooinstead ofqaz.php#foo.