I currently have setup an Nginx location block that matches a uri if and only if it starts and ends with /auth/test.php
. The only match would be http://host/auth/test.php
.
location ~ ^/auth/test\.php$ {
# Use try files or the if statement below. try_files is preferred
# If the original URI ($uri) does not resolve into an existing file or directory, a 404 error is returned
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$; #
fastcgi_param USERNAME $arg_username;
fastcgi_param PASSWORD $arg_password;
fastcgi_pass unix:/var/run/php5-fpm.sock;
include fastcgi_params;
}
My understanding is that query parameters don't play a role when Nginx tries to match a location block. My script, test.php
, is processed when uri is of the form http://host/auth/test.php?username=blah&password=blah
. However, if I try a uri without the query parameters (http://host/auth/test.php
) the script test.php
gets downloaded by whomever requested it which isn't ideal. Is there a way in having Nginx not process this type of uri request? I thought the try_files
directive would take care of this case but apparently not. Thanks.