Welcome! Log In Create A New Profile


"if" statement breaks try_files?

November 03, 2011 09:52PM
I'm seeing something really weird. If I put an "if" statement
anywhere within the same block as a "try_files" then it stops working.
It always returns that the file exists even when it doesn't.

I'm testing against nginx-1.0.9 on a Linux host.

This can be tested with this simple.conf:

worker_processes 1;
events { worker_connections 1024; }
http {
server {
listen 80;
server_name localhost;
root /var/www;
index index.html index.htm index.php;

location ~ \.php($|/) {
try_files doesnotexist =405;
fastcgi_index index.php;
fastcgi_pass unix:/tmp/php.socket;

if ($uri) {}

fastcgi_param SCRIPT_FILENAME /var/www$fastcgi_script_name;
fastcgi_param HTTPS off;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param REDIRECT_STATUS 200;

If that "if ($uri)" statement is left in it never returns the 405
error when accessing whatever.php. If you comment out that "if" then
it works as expected and always returns the 405 error.

Any idea what is going on here?


nginx mailing list
Subject Author Posted

"if" statement breaks try_files?

7 November 03, 2011 09:52PM

Re: "if" statement breaks try_files?

Nginx User November 04, 2011 02:14AM

Re: "if" statement breaks try_files?

7 November 04, 2011 10:04AM

Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 325
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready