0

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 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

4 Comments

what does !^((css|js|images)/.*)$ exactly do?
Just matches any url that doesn't (!) start (^) with css/ or js/ or images/
thanks! I guess I must turn on the mod-rewrite engine as well?
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?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.