This must be a simple fix, but I just can’t figure it out!
I am including the header via PHP into each new page, the header contains the CSS and scripts etc.
Only problem is since the page is in a different directory, when I link to the header like ../header etc it looks fine but the included scripts, are the included via a short URL e.g. /js/script.js
Which means on the page (in another directory) the scripts do not work!
I’m finding it hard to explain but take a look at this:
http://www.healthygit.com/
If you view the source all the scripts link fine.
Now look at this:
http://www.healthygit.com/fitness/running.php
If you try to click on a script to view it, it takes you to a 404 or in this case 302’s you to the homepage.
Easy peasy, your source for the scripts, stylesheets etc. should have a
/in front of them, that way the header file will always refer to the files from the root of the site.I.e. this:
Should become
This way it will always look for the files from the root of the site.
The same applies with CSS files, i.e.
/css/whatever.css.