The problem
I got the 500 Internal Server Error Nginx error when I post to other controller…
When I examined the /var/log/nginx/error.log, it show the following error;
[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/"
I can work with default controller, which welcome controller. But for others controller (in this case; new_order function of order controller), it show this error.
Context
OS: Ubuntu 14.04
WebServer: Nginx 1.4.6
Framework: CodeIgniter 2.2.6
Base URL: http://60daysonline.co/
Base CodeIgniter directory: http://60daysonline.co/60d/
Configuration
File: /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 = / {
# return 301 http://$server_name/60days/;
}
location / {
try_files $uri $uri/ /index.php;
proxy_cache STATIC;
proxy_cache_lock on;
proxy_cache_valid 200 1d;
proxy_cache_use_stale updating;
}
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)$ {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) { return 404; }
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /60d/ {
try_files $uri $uri/ /60d/index.php$uri?$query_string;
}
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’s config.php
$config['base_url'] = "";
$config['index_page'] = 'index.php';
$config['uri_protocol'] = "REQUEST_URI";`
The progress I did so far to solve this issue but still have no luck
I modified the /etc/nginx/sites-available/default until it look like this;
location / {
try_files $uri $uri/ /index.php;
}
location ~ [^/]\.(hh|php)(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.*)$;
if (!-f $document_root$fastcgi_script_name) { return 404; }
...
}
and the following is new codeIgniter’s config file;
$config['base_url'] = "http://60daysonline.co/60d";
$config['index_page'] = '';
$config['uri_protocol'] = "REQUEST_URI";`
The new problem
I found that when I put the empty string to $config['index_page']
, the system will route me to the url that exclude index.php from address such as
60daysonline/60day//order/new_order
. It show me the 404 error page.
If I put ‘index.php’ to $config[‘index_page’], the url will become 60daysonline/60day/index.php/order/new_order
. At there, I can see the ‘root controller page’, which is the same page as base url (60daysonline/60d).
It’s seem like the system not call function in controller at all (in this case; funciton new_order in Order controller). This is the new problem that I have to continuous find the solution.