禁用特定目录的codeigniter错误页面

时间:2014-03-11 12:11:29

标签: php .htaccess codeigniter

我的CodeIgniter项目位于www.mydomain.com/project

因为自定义404错误页面工作正常,我通过在routes.php

中编写以下行来配置
$route ['404_override'] = 'content/not_found/'; //Here, content is controller, not_found() is method to handle 404 error.

我的codeigniter项目下有一个名为 sub_project 的子目录,即www.mydomain.com/project/sub_project

我想将custom_404.html用于我的 sub_project (未在CodeIgniter框架中编码)。为此,我找到了.htaccess设置404错误页面的示例。

我创建了文件:/project/sub_project/.htaccess

ErrorDocument 404 /project/sub_project/custom_404.html

现在,我的sub_project发生了什么,它显示了www.mydomain.com/content/not_found/错误页面而不是custom_404.html

目录结构:

 www.mydomain.com
                |--/project                             (CodeIgniter)
                |--/project/applications/routes.php     (routes.php location)
                |--/project/sub_project                 (Other project in core PHP)
                |--/project/sub_project/.htaccess       (.htaccess location)
                |--/project/sub_project/custom_404.html (New error page)

1 个答案:

答案 0 :(得分:1)

RewriteEngine on 
ErrorDocument 404 /project/sub_project/custom_404.html