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? I only know the mod-rewrite engine is my friend here.

link|improve this question

50% accept rate
feedback

3 Answers

To complete Khal Weir's answer, the resulting rule should be something like :

RewriteBase /
RewriteCond %{REQUEST_URI}!^(/css/|/js/|/images/|/robots.txt)
RewriteRule . /index.php/ [L]
link|improve this answer
feedback

Either you filter it as the other recommended it or you filter for files existing on the hard drive:

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php/ [L]

These days most CMS systems filter it like this.

link|improve this answer
+1 This is actually a "better" way to do it than what I proposed. – François Feugeas Feb 12 '10 at 17:08
feedback

you can do something like

RewriteCond $1 !^(css|js|images|robots.txt)

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.