Problem with query strings using CodeIgniter with nginx - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: Problem with query strings using CodeIgniter with nginx (/showthread.php?tid=34428) |
Problem with query strings using CodeIgniter with nginx - El Forum - 09-29-2010 [eluser]mptre[/eluser] Hi! I'm having troubles using CodeIgniter with nginx. The setup works fine until a request includes a query string. CodeIgniter then prompts me with a 404. I've changed the URI protocol to REQUEST_URI in order to work with the CGI. See nginx config below. Any ideas would be much appreciated! Thanks in advantage! Code: server { Problem with query strings using CodeIgniter with nginx - El Forum - 09-29-2010 [eluser]Brian Loomis[/eluser] I'm having the exact same problem right now and it's driving me up the wall. I have to have a query string working and nginx seems to bark at what I'm doing. I even have the 404 going explicitly to index.php with 404 still showing. server { listen 192.168.100.194:80; server_name feed.xyz.com; access_log /home/webuser/log/access.log; error_log /home/webuser/log/error.log; if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?/$1 last; break; } # catch all error_page 404 /index.php; location / { # set 404 error page error_page 404 = /index.php; # set the doc root root /var/www/html/feed.xyz.com; # pass scripts to FastCGI fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; include /usr/local/nginx/conf/fastcgi.conf; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_FILENAME /var/www/html/feed.xyz.com/index.php; fastcgi_intercept_errors on; } location ~ /\.ht { deny all; } } Problem with query strings using CodeIgniter with nginx - El Forum - 10-22-2010 [eluser]mptre[/eluser] Bump. Problem with query strings using CodeIgniter with nginx - El Forum - 10-29-2010 [eluser]Unknown[/eluser] I've the same problem (facebook generates links with query params like ref, so i can't avoid it). I'm using php-fpm wiht 5.3.3 and what i've been found out by sniffing in to the network traffic between nginx and fpm is looks like this: Code: QUERY_STRING/some/url/123&ref=nf..REQUEST_METHODGET..CONTENT_TYPE..CONTENT_LENGTH..SCRIPT_NAME/some/index.php.1REQUEST_URI/some/url/123?ref=nf the nginx conf looks like this (the code is in a subfolder, but that's irrelevant for the problem): Code: location /some { as you can see, nginx seem to "repair" (replaces ? with a & in $query_string) the bugus query string (after the rewrite it will look like this: domain.com/some/index.php?/url/123?ref=nf), and because of that, the AUTO uri_protocol fails to find the "param" in the $_GET array in search of routing sources in the system/libraries/URI.php:68 (ci version 1.7.2) because of the count($_GET) == 1 condition. my solution is: 1) use AUTO uri_protocol 2) subclass the CI_URI class, copy the function "_fetch_uri_string" to the new one and remove the count($_GET) == 1 from the condition (original in line 68). Also enables you to hack back proper GET params from $_SERVER['REQUEST_URI'] but that's is an other story (-: |