Nginx和Codeigniter重写错误

我试图让基于codeigniter的nginx运行的网站。 有些部分工作,但有些失败。 我注意到在访问日志index.php有时有两个斜杠末尾insted我也无法正确地得到我的post(返回404)。

我的nginx conf对于我的默认站点如下(这是服务器上的唯一一个)

server { server_name xxx.com; return 301 $scheme://www.xxx.com$request_uri; } server { root /srv/www/xxx; index index.php index.html index.htm; server_name www.xxx.com; # removes trailing "index" from all controllers if ($request_uri ~* index/?$) { rewrite ^/(.*)/index/?$ /$1 permanent; } if (!-e $request_filename) { rewrite ^(.*)$ /index.php/$1 last; break; } location \ { try_files $uri $uri/ @no_php_ext; } # catch all error_page 404 /index.php; location ~ \.(php)$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /srv/www/xxx/$fastcgi_script_name; include fastcgi_params; #fastcgi_read_timeout 900; } location @no-php-ext { rewrite ^(.*)$ index.php/$1 last; } } 

我在重写中尝试了很多改变,但没有成功。 任何帮助真的很感激。

这个为我工作。 所有页面现在返回200。 我仍然有cron工作probs,但应该在另一个问题。

 server { root /srv/www/xxx; index index.php index.html index.htm; server_name www.xxx.com; access_log /var/log/nginx/xxx.access.log; error_log /var/log/nginx/xxx.error.log; location = / { try_files $uri $uri/ /index.php; rewrite ^/(.*)$ /index.php; } location / { # Check if a file or directory index file exists, else route it to index.php. try_files $uri $uri/ /index.php; location = /index.php { fastcgi_pass unix:/var/run/php5-fpm.sock; include fastcgi_params; } } location ~ \.php$ { return 444; } }