I think I’m either misunderstanding the purpose of the log_not_found
directive or maybe there is a bug in nginx 0.7.8. In May 2008 Igor
recommended [1] the following configuration snippet to hand off all
requests for non-existing files to PHP:
location / {
error_page 404 = /index.php;
}
But this creates an entry in my error_log for each request that is
handed off to PHP. Michael S. then pointed me to the log_not_found
directive, but adding “log_not_found off;” to the configuration file
does not seem to have any effect, no matter where I put it (http, server
or location block).
The error I get originates from src/http/modules/ngx_http_index_module.c
and reads
2008/08/11 10:04:17 [error] 5887#0: *1 “/doc/root/artikel/index.php” is
not found (2: No such file or directory), client: 127.0.0.1, server:
www.example.org, request: “GET /artikel/ HTTP/1.1”, host:
“www.example.org”, referrer: “http://www.example.org/”
What am I doing wrong?
I could, of course, change the error_log directive to only log critical
events, but I fear that I would miss some (more) important errors then.
Kind regards
Steffen W.
[1] http://article.gmane.org/gmane.comp.web.nginx.english/4739
[2]
The Life and Times of Michael Shadle » WordPress+nginx rewrite rules – stop the insanity!
On Mon, Aug 11, 2008 at 10:20:36AM +0200, Steffen W. wrote:
handed off to PHP. Michael S. then pointed me to the log_not_found
“www.example.org”, referrer: “http://www.example.org/”
What am I doing wrong?
I could, of course, change the error_log directive to only log critical
events, but I fear that I would miss some (more) important errors then.
The attached patch should fix the bug.
Igor S. wrote:
not found (2: No such file or directory), client: 127.0.0.1, server:
www.example.org, request: “GET /artikel/ HTTP/1.1”, host:
“www.example.org”, referrer: “http://www.example.org/”
What am I doing wrong?
I could, of course, change the error_log directive to only log critical
events, but I fear that I would miss some (more) important errors then.
The attached patch should fix the bug.
It does, thank you very much!
Steffen
Igor S. wrote:
not found (2: No such file or directory), client: 127.0.0.1, server:
www.example.org, request: “GET /artikel/ HTTP/1.1”, host:
“www.example.org”, referrer: “http://www.example.org/”
What am I doing wrong?
I could, of course, change the error_log directive to only log critical
events, but I fear that I would miss some (more) important errors then.
The attached patch should fix the bug.
I still have one problem when using this method: First I noticed that
the redirected requests were missing the GET data, but I was able to
solve this problem by using
error_page 404 = /index.php?$args;
instead of
error_page 404 = /index.php;
But POST data is missing, too. At least the $_POST array in PHP is empty
when the request is redirected by the error_page directive. However, the
cookies somehow make it through. How can I solve this problem?
I have reverted to the following configuration for now:
if (-f $request_filename) {
break;
}
rewrite ^ /index.php last;
Kind regards
Steffen W.
On 8/12/08, Steffen W. [email protected] wrote:
But POST data is missing, too. At least the $_POST array in PHP is empty
when the request is redirected by the error_page directive. However, the
cookies somehow make it through. How can I solve this problem?
I can see the differerence I think - cookies are sent on each request,
GET is sent via the query string… However, I would expect that
error_page works like an internal rewrite so it should maintain the
same POST/etc. and be transparent to the end user.
Igor could this be allowed? error_page should be treated like an
internal rewrite in my opinion.
On Tue, Aug 12, 2008 at 12:58:03PM +0200, Steffen W. wrote:
}
2008/08/11 10:04:17 [error] 5887#0: *1 “/doc/root/artikel/index.php” is
But POST data is missing, too. At least the $_POST array in PHP is empty
when the request is redirected by the error_page directive. However, the
cookies somehow make it through. How can I solve this problem?
I have reverted to the following configuration for now:
if (-f $request_filename) {
break;
}
rewrite ^ /index.php last;
Try the attached patch. The POST method will be changed to GET while
internal redirection, but the POST body will remain. Probably $_POST
array will contain the body data.