Mod_rewrite does not load css and js files

I have a strange problem with mod_rewrite condition / rule.

This is the condition and rule that I use.

RewriteEngine On

RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-l

RewriteRule ^(.*)$ index.php?params=$1 [QSA,L]

My problem is that if I visit www.example.com and www.example.com/page, it loads normally, but when I try to download www.example.com/page/category it loads the page, but cannot find css and javascript. He tries to load them from the / css page instead of the / directory.

Any thoughts on what I did wrong? I had a search here and tried a few things, for example, add

RewriteCond $1 !\.(js|ico|gif|jpg|png|css|html|swf|mp3|wav|txt)$ 

and

RewriteRule ^(images|css|javascript)(.*)$ index.php?params=$1 [QSA,L]

But that didn't seem to make much difference.

Thanks for reading

+5
source share
2 answers

, -, .

, / (), , , -, CSS.

/page/category (), , , page. , CSS , /page/sub -directory, . , 404 , CSS.

- CSS, , , . , . , , , . , :

src="image-name.png"

src="/image-name.png"

, .

RewriteCond, RewriteRule :

RewriteRule ^([a-z]+(?:/[a-z]+)*)$ index.php?params=$1 [QSA,L]

-, (), CSS .

+2

, base "/" ?

+1

All Articles