Relative URL Paths / ./ ../?

I have a live site in the format www.site.com, with www.site.com/header.php that references style.css and favicon.ico, both of which are in the root directory. header.php is referenced on every page. In header.php, the reference is done as "/style.css", so other pages within folders (such as www.site.com/docs/file.php) will pull the files correctly. However, when I shift to localhost, the entire site is shifted down a directory, with localhost becoming root. The references no longer work, as they look for localhost/style.css for example. If I fix this with "./style.css", the main files work correctly, but the files in folders won't, as they reference themselves (incorrect).

Do I need to add an 'if' condition for if the root is localhost, or is there an easy way around this? I could always make a second header, in the child folder, that references the parent -- though I feel that this is not neccessary.

Help would be greatly appreciated!

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 Q2A.ES - All rights reserved.