$request_uri in rewrite and try_files

freetg freetgm at gmail.com
Mon Apr 14 19:16:37 UTC 2014


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.

PHP 5.4.22


        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
My question is why $request_uri in try_files and rewrite but get different

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20140415/0fafa3a3/attachment.html>

More information about the nginx mailing list