【发布时间】:2015-06-11 01:19:32
【问题描述】:
所以,我有下一个问题。这是我的 nginx 配置
server {
disable_symlinks off;
listen 80;
server_name g9tv.loc;
charset utf-8;
#access_log logs/host.access.log main;
location / {
root /home/dejmos/www/g9tv;
index index.html index.htm index.php;
try_files $uri $uri/ /index.php;
}
error_page 404 /index.php;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /home/dejmos/www/g9tv;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_intercept_errors on;
root /home/dejmos/www/g9tv;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/dejmos/www/g9tv$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
当我转到服务器上不存在的页面时,我得到了 nginx 提供的 404 页面,但我需要得到 codeigniter show_404() 函数提供的 404 页面。
【问题讨论】:
-
在application/config下有一个名为routes.php的文件,可以编辑404页面如$route['404_override'] = 'welcome';
-
如果我使用 Apache Codeigniter 渲染自己的 404 页面。如果我使用 Nginx,它会呈现 nginx-404 页面。这是一个问题。自定义 404 页面也不起作用
标签: php codeigniter nginx http-status-code-404