Dejwid
Dejwid

Reputation: 1

mod_rewrite / breaks JS and CSS files

I have some problem with Mod Rewrite Rules and I think we may help me.
My .htaccess:

RewriteEngine On
RewriteRule ^img/(.+)$ http://www.dejwid.pl/demo/img/$1 [L]
RewriteRule ^(.+)$ index.php?p=$1

in index.php I divide $_GET['p'] using '/':

$params = explode('/', $_GET['']);

My problem:
if I using '/' images, js files, css files don't work.
I think the server can't find it because I'm using '/'.
If I use ',' or '-' etc. everything works great.
However I need address like this: domain/blog/123/Some-Title

Upvotes: 0

Views: 123

Answers (1)

bmb
bmb

Reputation: 6248

Your rule that matches ^(.+)$ is probably matching on your css and js files.

It is common to put these two conditions in front of a rule, to prevent the rule from matching when the URL is a real file, such as a css or js file:

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

Upvotes: 2

Related Questions