Welcome! Log In Create A New Profile

Advanced

$request_uri in rewrite and try_files

April 14, 2014 03:18PM
Hi,

When I try to use rewrite to replace try_files, my php application report
error. Finally I find $_SERVER["PATH_INFO"] is different between try_files
and rewrite.

nginx/1.4.4
PHP 5.4.22

try_files:

try_files $uri $uri/ /index.php$request_uri;

url: http://example.com/a/b/c?d=1 , $_SERVER["PATH_INFO"] is /a/b/c

but, when I use rewrite:

if ( $host = "example.com" ) {
set $example 1$example;
}
if ( $uri !~ \.(ico|gif|png|jpeg|css|js|xml|html|shtml|swf|mp3) ) {
set $example 11$example;
}
if ( $example = 111 ) {
rewrite ^ /index.php$request_uri last;
}

url: http://example.com/a/b/c?d=1 , $_SERVER["PATH_INFO"] is /a/b/c?d=1

Obviously try_files is right , I can use $uri in rewrite to solve this
problem.
My question is why $request_uri in try_files and rewrite but get different
$_SERVER["PATH_INFO"] ?

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

$request_uri in rewrite and try_files

shawk April 14, 2014 03:18PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 270
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