【问题标题】:Codeigniter + Nginx must render 404 page provided by frameworkCodeigniter + Nginx 必须渲染框架提供的 404 页面
【发布时间】: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


【解决方案1】:

问题已解决。它是由子文件夹引起的。我将 Codeigniter 放到根文件夹,现在一切正常。

【讨论】:

    猜你喜欢
    • 2019-10-25
    • 2016-11-22
    • 2016-04-16
    • 2015-08-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-02
    • 2020-11-12
    相关资源
    最近更新 更多