Incorrect $request_filename in 1.0.5?

Hi, I’ve recently compiled nginx 1.0.5 on localhost (debian), and have
set up a test site so that i may access it http://testsite in the
browser (set “testsite” to 127.0.0.1 in /etc/hosts and an nginx server
config with root /var/www/testsite;)

i’ve been having some problems with some rewrites, and started pushing
some of nginx vars out to php as fastcgi_param’s to troubleshoot. i’ve
noticed that $request_filename is incorrect. it’s showing as
“/var/www/testsiteindex.php” when accessing http://testsite/foo/bar/
(which is being redirected to index.php?q=foo/bar/).

i’m not sure if it’s my set up as I’m fairly new at this!

Thanks

Posted at Nginx Forum:

$request_filename will change when you rewrite the request, even if you
just do an internal rewrite.
$request_filename is defined as root or alias directive + current URI.

So if you have a root defined as /var/www/testsite and you redirect to
index.php then you’ll get /var/www/testsiteindex.php

URIs in Nginx always start with a / so it’s generally a good idea to
rewrite to /index.php instead of index.php

Posted at Nginx Forum:

Hi, thanks for the reply. Ok, so I’ve changed to /index.php, but
$_SERVER[‘SCRIPT_FILENAME’] is now /var/www/testsite//index.php (double
slash before index.php)

while the nginx $request_filename is correct. Surely that isn’t right?

Posted at Nginx Forum:

Full points to you Sir! Thanks!

Posted at Nginx Forum:

On Sun, Aug 28, 2011 at 10:18:51AM -0400, Roger Smith wrote:

Hi, thanks for the reply. Ok, so I’ve changed to /index.php, but
$_SERVER[‘SCRIPT_FILENAME’] is now /var/www/testsite//index.php (double
slash before index.php)

while the nginx $request_filename is correct. Surely that isn’t right?

You probably have the directive

fastcgi_param  SCRIPT_FILENAME  $document_root/$fastcgi_script_name;

It should be changed to

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;


Igor S.