I’m dealing with some strange behavior that I don’t understand.
So if I type:
http://localhost/site/index.php
The http server will return a page with no problems at all, a slash after the index.php will generate a page without any style!
http://localhost/site/index.php/
How can i solve this?
The beneath CSS link isn’t working why?
<link rel="stylesheet" type="text/css" href="/css/fonts.css" />
This will work for the slash but if I add something after the slash then I get the all website without styles.
<link rel="stylesheet" type="text/css" href="http://localhost/site/index.php/css/fonts.css" />
EDIT:
All of the requested url are OK after adding the complete path on the href’s with this function:
function baseUrl(){
return ("http://".$_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']));
}
Anyway, I’ve added some rules to the .acccess so now I can’t type slash after the index.php but if I type something after the slash everything falls apart 🙁
Check if your
<link />tagshrefattributes and<img />tagssrcattributes are prepended with/:Bad:
Good:
This way you are certain that browser will compute correct path.