views:

55

answers:

1

Example: My Site gets called like that:

www.mysite.com/controller/method/parameter1/parameter2

Now, .htaccess needs to rewrite this URL into:

www.mysite.com/index.php/controller/method/parameter1/parameter2

But the problem is: In case of an img, css or js directory, no redirection should happen.

How can I achieve this? What must I put to .htaccess? I just added this line but nothing happens:

RewriteCond $1 !^(css|js|images)
+1  A: 

I haven't tested it, but this should work:

RewriteRule !^((css|js|images)/.*)$ index.php%{REQUEST_URI} [L, NE]

%{REQUEST_URI} will be the original /controller/method... stuff, including the ?query part hopefully. NE prevents double escaping of stuff, and L means no further rules are applied.

Mike Weller
what does !^((css|js|images)/.*)$ exactly do?
openfrog
Just matches any url that doesn't (!) start (^) with css/ or js/ or images/
Mike Weller
thanks! I guess I must turn on the mod-rewrite engine as well?
openfrog
I tried that, but I'm getting an Internal Server Error. RewriteEngine is on. However, this one worked with no error: RewriteRule index.html$ index.php so my mod-rewrite is basically fine, I guess?
openfrog