1
votes

I have a simple nginx rewrite rule below :

    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php$1 break;
    }

It works fine with urls' like http://mydomain.com/controller/action, however when the requested url is something like :

    http://mydomain.com/index.php/controller/action 

it failed to recognize that index.php is an existing file, in which case the rewrite shouldn't take place.

How can I fix this? Thanks for your help.

1

1 Answers

0
votes

You'll want a regular expression which says "any string which does not contain .php", like so:

^((?!\.php).)*$

If this causes errors because the php file doesn't exist, you'll need to use a custom 404 error to redirect your user elsewhere.