Messenger Stuff Community Forums

Full Version: RewriteEngine
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok, so I've got the apache rewrite engine running on a site I am designing: all working fine, except for one problem: if I was to navigate to http://localhost/ (were the site is) the style sheet won't load but if I was to go to say the desktop page (/desktop/ ) it would. I just can't seem to find a fix.

Heres some of the code:

Code:
RewriteEngine on
RewriteRule ^home/ index.php?act=index
RewriteRule ^links/ index.php?act=links
RewriteRule ^contact/ index.php?act=contact
RewriteRule ^projects/ index.php?act=projects
RewriteRule ^desktop/ index.php?act=desktop

Then in the main index.php file:
Code:
<style type="text/css">@import url(../css/style.css);</style>

Note: The site uses php includes (?act=$)

Thanks.
.htaccess is a file that tells the server to do an action, your browser does not read it. Therefore /desktop/ is treated like a real directory, and the problem you have is your '../css/' goes back two directories:

Code:
<link rel="stylesheet" href="/something/otherthing/css/style.css" type="text/css"/>

That could work better, it checks the root directory and it should load fine with every page. mod_rewriting is basically creating fake directories, your browser does not know it is not real :p.
hmm that doesn't seem work, its still not loading the css:

Code:
<link rel="stylesheet" href="/css/style.css" type="text/css"/>
Chris Wrote:hmm that doesn't seem work, its still not loading the css
on the http://localhost/ page or the http://localhost/whatever/ ??
Chris Wrote:
Code:
RewriteEngine on
RewriteRule ^home/ index.php?act=index
RewriteRule ^links/ index.php?act=links
RewriteRule ^contact/ index.php?act=contact
RewriteRule ^projects/ index.php?act=projects
RewriteRule ^desktop/ index.php?act=desktop
This might be easier to do:
Code:
RewriteEngine on
RewriteRule ^(.*)/ index.php?act=$1
--
What is the absolute path to your css?
("/css/style.css" should work on a domain, but it depends on the path localhost is installed on)
Reference URL's