【发布时间】:2016-05-30 09:11:26
【问题描述】:
我是 CodeIgniter 的新手,我的路由配置存在一些问题。
如果我访问一个页面,一切正常
http://localhost/index.php/class/controller
但是如果我添加一些随机参数
http://localhost/index.php/class/controller/randomStuff
它显示没有 CSS 或 JS 的页面,但我想显示 404 错误页面。
这是我的 route.php 文件
$route['stats'] = 'main/account';
$route['/'] = 'index.php';
$route['/(:any)'] = 'main/disperr'; //Tried this to solve the problem but doesn't work (disperr simply returns show_404())
$route['default_controller'] = 'main';
$route['all'] = 'main';
$route['404_override'] = 'errors/page_missing';
$route['translate_uri_dashes'] = FALSE;
提前感谢您的帮助。
编辑:感谢您的回答! 正确路由页面后,我仍然遇到缺少 css 的问题。 当我使用 twig 时,我将 base_url() 作为参数发送到我的视图,并将其添加到我的 CSS 和 JS 的路径中。 现在可以了。
【问题讨论】:
标签: codeigniter routing uri