remove if from code

Reinis Rozitis r at roze.lv
Wed Apr 26 10:54:20 UTC 2017


> Does anyone know how to rewrite this snippet?

> ## Execute PHP Scripts using FastCGI
> location ~ \.php(/.*)? {
>    if (!-e $request_filename) {
>        rewrite / /index.php last;
>    }

You can use try_files for that ( 
http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files )

location ~ \.php$ {
    try_files $uri /index.php;
}


p.s. obviously for this location you need to add php handling also.

rr 



More information about the nginx mailing list