我有一个使用codeigniter构建的网站http://example.com 2.默认控制器为
$route['default_controller'] = "domain";
如果我尝试访问pageX,则链接应为http://example.com/en/domain/view/pageX
我想通过输入
http://example.com/pageX
我试过了
$route['(:any)'] = "view/$1"; ==> it gives 404 Page Not Found
$route['(:any)'] = "domain/view/$1"; ==> it redirects to homepage with link shown as http://example.com/en/pageX
$route['(:any)'] = "en/domain/view/$1"; ==> it gives 404 Page Not Found
但他们没有为我工作。
修改
添加:
$route['(:any)'] = 'domain/view/$1';
$route['en/blog'] = 'domain/view/blog';
example.com/blog
可以正常使用
但是除了管理页面之外,我需要它更全面地覆盖所有页面,如下所示:
$route['(:any)'] = 'domain/view/$1';
$route['^(?!admin).*'] = 'domain/view/$o';
//The above routes will show the home page only for whatever i try!!
我必须添加到routes.php
的路线是什么?
答案 0 :(得分:0)
$route['default_controller']
。使用$route['404_override']
获取完整的“全部捕获”。
要使路由模式正常工作,请尝试以下方法:
$route['[^/]*/(.*)'] = 'en/domain/view/$1';
答案 1 :(得分:0)
我通过这样做来解决了我的问题
$route['^[a-z]+$'] = 'domain/view/$1'; $route['([a-z]{2})/([a-z_]{1,50})'] = 'domain/view/$2';