l'arbre
l'arbre

Reputation: 719

NGINX rewrite broke index

I have an NGINX rewrite that looks like this:

 if ( $uri !~ ^/(index\.php|index|css|img|fonts|js|robots\.txt|favicon\.ico|slick) ) {

            rewrite ^(.*)$ $1.php;
    }

Basically it's supposed to remove .php extensions from all files that are not contained in css, img, fonts etc. It works fine, but this prevents my index.php file from showing when accessing /. To me, these rewrites are complete chinese, therefore, i cannot figure it out. Can anyone tell me, why this happens?

Upvotes: 2

Views: 54

Answers (1)

Richard Smith
Richard Smith

Reputation: 49692

You are probably rewriting / to /.php. You could make your rewrite a little more selective with:

rewrite ^(/.+)$ $1.php;

Upvotes: 2

Related Questions