我的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)
答案 0 :(得分:1)
试
RewriteEngine on
ErrorDocument 404 /project/sub_project/custom_404.html