Welcome! Log In Create A New Profile

Advanced

Nginx, PATH_INFO, and url-rewriting: i must be missing something.

January 18, 2011 01:45PM
I'm switching from Apache to Nginx/fcgi and I'm having a small issue while attempting to setup the applications rewrite rules.

The code handles routes via the use of PATH_INFO, e.g., example.com/foo/bar/ will be routed to example.com/index.php/foo/bar/

I've modified the server configuration to pass PATH_INFO:

[code]
location ~ \.php$ {
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;

fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME /var/www/public$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
}
[/code]


And the rewrite handler:
[code]
location / {
root /var/www/public;
index index.html index.htm index.php;

if (!-f $request_filename) {
rewrite ^(.*)/(.*)$ /index.php/$2 break;
}
}
[/code]
With '__rewrite_log on__', the url's appear to be routing properly:
[code]
[error]: *2 open() "/var/www/public/index.php/test" failed (20: Not a directory), client: 192.168.0.254, server: example.com, request: "GET /test HTTP/1.1", host: "example.com", referrer: "http://example.com/index.php"
[/code]
However, it appears to be looking for the directory "test". How can I force it to request index.php, passing '/test' to the script?
Subject Author Posted

Nginx, PATH_INFO, and url-rewriting: i must be missing something.

uid_b January 18, 2011 01:45PM

Re: Nginx, PATH_INFO, and url-rewriting: i must be missing something.

Francis Daly January 18, 2011 02:32PM

Re: Nginx, PATH_INFO, and url-rewriting: i must be missing something.

uid_b January 20, 2011 05:12PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 74
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready