我有一个网站,使用CodeIgniter,并在NGinx下运行。
我使用这些重写规则来清理URL,并从URL中删除index.php。
不幸的是,由于控制器没有收到任何参数,所以对于向控制器发送POST参数的AJAX查询有问题。
使用Firebug Lite,我可以看到我给控制器提供了正确的POST参数,但是当我在控制器中打印它们时,什么也不打印。
我想这是从重写规则,这似乎没有通过沿URL的参数,但我不知道如何解决这个问题。
会有人有一个想法?
这里是重写规则,可能更容易让他们在这里,而不是在其他网站:
if ($host ~* ^www\.(.*)) { set $host_without_www $1; rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent; } # canonicalize codeigniter url end points # if your default controller is something other than "welcome" you should change the following if ($request_uri ~* ^(/welcome(/index)?|/index(.php)?)/?$) { rewrite ^(.*)$ / permanent; } # removes trailing "index" from all controllers if ($request_uri ~* index/?$) { rewrite ^/(.*)/index/?$ /$1 permanent; } # removes trailing slashes (prevents SEO duplicate content issues) if (!-d $request_filename) { rewrite ^/(.+)/$ /$1 permanent; } # removes access to "system" folder, also allows a "System.php" controller if ($request_uri ~* ^/system) { rewrite ^/(.*)$ /index.php?/$1 last; break; } # unless the request is for a valid file (image, js, css, etc.), send to bootstrap if (!-e $request_filename) { rewrite ^/(.*)$ /index.php?/$1 last; break; }
谢谢!
我认为,使用重写(如在Apache)不转发发布数据,而是尝试configurationnginx作为前端代理