【发布时间】:2016-12-19 00:23:29
【问题描述】:
我尝试了在 stackoverflow 中给出相同问题的所有答案。它给了我一个进步,但仍然找不到最终的解决方案。
问题
当我发布到其他控制器时出现500 Internal Server Error Nginx 错误..
当我检查 /var/log/nginx/error.log 时,它显示以下错误;
`[error] 17184#0: *8 rewrite or internal redirection cycle while internally redirecting to "/index.php/", client: 58.9.106.64, server: 60daysonline.co, request: "POST /60d/index.php/order/new_order HTTP/1.1", host: "60daysonline.co", referrer: "http://60daysonline.co/60d/"`
上下文
操作系统:Ubuntu 14.04
网络服务器:Nginx 1.4.6
框架:CodeIgniter 2.2.6
基本 CodeIgniter 目录:http://60daysonline.co/60d/
配置
文件:/etc/nginx/sites-available/default
server {
server_name www.60daysonline.co;
return 301 $scheme:/60daysonline.co$request_uri;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /home/him_aeng/goo_html/public_html;
index index.php index.html index.htm;
server_name 60daysonline.co;
location / {
try_files $uri $uri/ /index.php/$1?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/him_aeng/goo_html_public_html;
}
location ~ \.(hh|php)$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params
set $no_cache "";
if ($request_method !~ ^(GET|HEAD)$) {
set $no_cache "1";
}
if ($no_cache = "1") {
add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
add_header X-Microcachable "0";
}
if ($http_cookie ~* "_mcnc") {
set $no_cache "1";
}
fastcgi_no_cache $no_cache;
if ($no_cache = "1") {
add_header Set-Cookie "_mcnc=1; Max-Age=2; Path=/";
add_header X-Microcachable "0";
}
if ($http_cookie ~* "_mcnc") {
set $no_cache "1";
}
fastcgi_no_cache $no_cache;
fastcgi_cache_bypass $no_cache;
fastcgi_cache microcache;
fastcgi_cache_key $scheme$host$request_uri$request_method;
fastcgi_cache_valid 200 301 302 10m;
fastcgi_cache_use_stale updating error timeout invalid_header http_500;
fastcgi_pass_header Set-Cookie;
fastcgi_pass_header Cookie;
fastcgi_ignore_headers Cache-Control Expires Set-Cookie;
fastcgi_buffer_size 128k;
fastcgi_buffers 256 16k;
fastcgi_busy_buffers_size 256k;
fastcgi_temp_file_write_size 256k;
fastcgi_read_timeout 240;
}
location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)$ {
log_not_found off;
access_log off;
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
# deny access to apache .htaccess files
location ~ /\.ht {
deny all;
}
}
CodeIgniter 的 config.php
$config['base_url'] = "";
$config['index_page'] = 'index.php';
$config['uri_protocol'] = "REQUEST_URI";
到目前为止我所做的进展都是按照这里的说明进行的
我修改了 /etc/nginx/sites-available/default 直到它看起来像这样;
location / {
try_files $uri $uri/ /index.php;
}
location ~ [^/]\.(hh|php)(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) { return 404; }
...
}
以下是新的codeIgniter的配置文件;
$config['base_url'] = "http://60daysonline.co/60d";
$config['index_page'] = '';
$config['uri_protocol'] = "REQUEST_URI";
新问题
我发现当我将空字符串放入$config['index_page'] 时,系统会将我路由到将index.php 从地址中排除的url,例如
60daysonline/60day//order/new_order。它显示了 404 错误页面。
如果我将 'index.php' 放入 $config['index_page'],则 url 将变为 60daysonline/60day/index.php/order/new_order。我看到了“根控制器页面”,它与基本 url (60daysonline/60d) 是同一页面。
似乎系统根本没有调用控制器中的函数(在这种情况下;订单控制器中的函数 new_order)。这是我必须不断寻找解决方案的新问题。
【问题讨论】:
-
我想尝试一次,将
base_url删除并删除index.php -
@VivekSingh 当我根据您的建议更改 config.php 时,系统会将我发送到
404 page not found页面。
标签: php .htaccess codeigniter nginx