I have the following issue. for user's comfort, i am using RewriteEngine (.htaccess) so instead of showing the following "http://localhost/index.php?display=subject&id=15" it's actually "http://localhost/subj/15" The problem comes when i am trying to insert stylesheets. when i put "<link rel="stylesheet" href="stylesheets/main.css" type="text/css" /> " Code (markup): then it works for the main page which is just "http://localhost" but it doesn't work on the subjects page, i have to add <link rel="stylesheet" href="[B]..[/B]/stylesheets/main.css" type="text/css" /> Code (markup): and then it doesn't work for the main page.. it considers "/subj/" as a sub folder... how can i make it work for both scenarios? it used to be fine on a different server but on my local machine it causes this issue... i don't think i can define a "root_path" like i do it with php..
why not just use the complete url path of the css... eg <link rel="stylesheet" href="http://site.com/stylesheets/main.css" type="text/css" /> HTML: or just store it on a php variable <link rel="stylesheet" href="<?=$root?>/stylesheets/main.css" type="text/css" /> PHP:
The problem is that you are referencing a relative path. Use absolute path like this: <link rel="stylesheet" href="/stylesheets/main.css" type="text/css" /> Note the "/" before stylesheets and make sure stylesheets is a directory at the root html level.