Question

I'm using nginx with PHP-FPM on a ISPConfig3 server.

I put the following rewrite-rule in my nginx-directives (to make prettier links in Pydio):

location ~ \.php$ {
        try_files @php;
    }

location @php {
        try_files $uri =404;
        include /etc/nginx/fastcgi_params;
        fastcgi_pass 127.0.0.1:9026;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_intercept_errors on;
    }

proxy_set_header X-Accel-Mapping /var/www/XXXYYY.com/pydio/data/=/data/;

location /conf/       { deny all; }
location /data/       { internal; }

location /data/public/ {
    try_files $uri $uri.php =404 last;
}

I want URLs in pydio.XXXYYY.com/data/public/* to have a .php-extension added. This rule finds the files without the .php in the address bar but now they are downloaded instead of executed.

Since I use ISPConfig3, the rewrites for .php-files (to have them executed by PHP-FPM) is above the stated part. But I thought adding "last" should take care of that.

What else could I try? Thank you!

Était-ce utile?

La solution

First of all, you misunderstand the try_files directive. There's no "last" argument and it doesn't work like you think. Please, check the documentation: http://nginx.org/r/try_files. It's technical documentation, read it literally, every word has meaning.

To solve your problem you have to remove two last arguments from try_files:

try_files $uri $uri.php =404 last;

should be replaced with:

try_files $uri $uri.php;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top