The author suggests creating directories and placing index.php in each one to hide the file extension.
When I do this I am noticing issues with the paths linking to my css files.
Ex. <link rel=“stylesheet” href=“<?php echo $_SERVER[‘DOCUMENT_ROOT’]; ?>websitename/css/reset.css” type=“text/css”>
When replacing $_SERVER[‘DOCUMENT_ROOT’] with the full root path it still doesn’t work.
I am at a loss. Any suggestions?
Have you double checked the error message, do you see the absolute path it is actually trying to access?
I am a nub with the doc root command but I have gotten to detailed and ended up with the file trying to access something like:
notice the second websitename/css that shouldn’t be there?
usually it is something simple maybe even missing a part of the actual path.
if you do know what the actual path, look at the error the document gives back and see if there isn’t just a typo. (thats about the extent of my knowledge with absolute path sorry i couldn’t be more help)
Using $_SERVER[‘DOCUMENT_ROOT’] gives the “physical” path. It’s good for scripts but browsers need “virtual” paths. They can be either “relative” or “absolute”.
If you hard-code it to
does that work?
Thank you for the feedback. Hard-coding does work. I didn’t realize that hard coding was the way to go. Since I am working locally I guess I will need to create a variable and define it so when I load it to the server it will work alright.
While working locally
$serverPath = “localhost/websitename/”;
<link rel=“stylesheet” href=“<?php echo $serverPath; ?>css/reset.css” type=“text/css”>
Then when I upload to the server, change the variable…
$serverPath = “websitename/”;
Thanks for your help. I understand better now.