Welcome! Log In Create A New Profile

Advanced

Re: Try_files and location blocks

Dave Hayes
June 24, 2011 02:16PM
appa@perusio.net writes:
> Also your later config could be simplified:
> server {
> ...
> location / {
> try_files $uri $uri/ /error.php?c=404 =404;
> }
> }

In this case, it seems to me that try files is looking for a file
named "/error.php?c=404" and not "/error.php". Try_files does not
appear to strip the arguments from the uri when trying. My evidence
for this is this debug line:

2011/06/24 03:11:58 [debug] 20773#0: *1 try to use file: "/error.php?c=403?"
"/home/www/testhome/error.php?c=403?"

This means that I can't see if error.php exists before I try to throw an
error with it. Right now it seems that my solution is:

location / {
try_files $uri $uri/ =404;
}

location ~ .php$ {
<..fastcgi stuff..>
}

error_page 404 = /error.php?c=404;

location = /error.php {
try_files /error.php @low_level_404
<..the -same- fastcgi stuff as above..>
}

location @low_level_404 {
return 404;
}

I am really trying hard not to use "if" but I am weakening here because
an "if" would let me use one and only one instance of fastcgi:

location / {
try_files $uri $uri/ =404;
}

location ~ .php$ {
<..fastcgi stuff..>
}

error_page 404 = @error_404
location @error_404 {
if (! -f $document_root/error.php) {
return 404;
}
rewrite ^ $scheme://$server_name/error.php?c=404
}

I'm also curious (in an academic way) as to what use case exists when
try_files has to match url arguments as a filename? I usually strongly
discourage the use of '?' and '&' characters in a filename.
--
Dave Hayes - Consultant - Altadena CA, USA - dave@jetcafe.org
>>> The opinions expressed above are entirely my own <<<

Treat people as if they are what they ought to be, and you
help them to become what they are capable of being.









_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

Try_files and location blocks

Dave Hayes June 23, 2011 05:38PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:04PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:12PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:20PM

Re: Try_files and location blocks

Dave Hayes June 23, 2011 06:30PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 06:48PM

Re: Try_files and location blocks

António P. P. Almeida June 23, 2011 07:02PM

Re: Try_files and location blocks

Dave Hayes June 24, 2011 02:16PM

Re: Try_files and location blocks

António P. P. Almeida June 24, 2011 02:52PM

Re: Try_files and location blocks

Dave Hayes June 24, 2011 07:04PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 166
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready