openfrog
openfrog

Reputation: 40735

How to insert an "index.php" into every url using .htaccess?

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)

Upvotes: 0

Views: 1162

Answers (1)

Mike Weller
Mike Weller

Reputation: 45598

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.

Upvotes: 1

Related Questions