try_files setup

Artur nginx at netdirect.fr
Fri Jul 10 15:16:31 UTC 2015


Hello,

I'm quite new to the advanced nginx configuration so I will need your
help. :)

I'm currently working on a nginx + php5-fpm (chrooted) + wordpress setup.
My basic setup works fine but I wanted to improve the try_files section.

My main concern is to correctly take in charge URIs by nginx or php5-fpm
depending on their types and existence.

My current setup for wordpress with nice permalinks
(http://host/wordpress_page/) :

location / {
        root   /content/chroot/htdocs;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$args;
    }

location ~ \.php$ {
        include        fastcgi_params;
        root           /htdocs;
        fastcgi_pass   127.0.0.1:1234;
        fastcgi_param  SCRIPT_FILENAME  $document_root$request_filename;
    }
   
    error_page  404              /404.html;
    #location = /404.html {
    # root   /usr/share/nginx/html;
    #}

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

The main problem is that if I try to get a non existing php file
(http://host/nonexisting.php) I get always "No input file specified."
fpm error.
I'd like to redirect here to a 404 error page instead.

In case I call a different non existing file (nonexisting.jpg) I get an
error displayed from Wordpress saying this page does not exist. I
suppose this is correct in a wordpress setup because of the permalinks
setup I described above.

Any help will be appreciate. :)

-- 

Best regards,
Artur.



More information about the nginx mailing list