Question

The following issue is driving me crazy, perhaps i am thinking to difficult.

Here is the thing, i developed a small MVC framework that works fine. Atleast without url rewriting.

The problem is that as soon as i use url rewrite, things like the css or images which are included in the templates are directed to the wrong directory.

If i type for example: http://www.domain.com/home then everything is fine and the css file get loaded from the http://www.domain.com/css/ directory.

But when i type: http://www.domain.com/home/ the css file won't be loaded, since its looking for the css files in http://www.domain.com/home/css/ Which is obliviously the wrong directory. It seems it sees home/ as a directory where it looks for the the included files.

If i don't use any url rewriting at all, just by typing: http://www.domain.com/index.php?slugs=home/ then there are no problems at all. So i don't think the problem is caused by my script so thats why i think the problems should be looked for in the .htaccess file.

Here is my htacces file:

RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d 
RewriteCond $1 !^(index\.php|images|css|robots\.txt)
RewriteRule ^(.*)$ /astrostrategy/index.php?slugs=$1 [L] 

Is there a way, that home/test/whatever(The segments) are not seen as a directory?

Hope my post made sense, i often think to complicated :P

Already thanx for any help! :)

Gr, Hermes.

Était-ce utile?

La solution

If Death's answer doesn't work you can always set the base tag to the url to use in relative paths

Autres conseils

it seems you're using relative to currect directory path for css. when you use http://www.domain.com/home/ browser takes home as directory and css file will be located in http://www.domain.com/home/css/. my suggestion is use relative to root path. Now you're using something like :

<link rel="StyleSheet" type="text/css" href="css/style.main.css" />

it's better to use absolute path or relative to root path.

<link rel="StyleSheet" type="text/css" href="/css/style.main.css" />
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top