[英]How to remove the controller name from url in codeigniter, and still be able to redirect on another controller?
我正在使用Codeigniter构建网站,并且将URL的显示方式从http://localhost/site_controller/home
更改为http://localhost/home
。
我已经通过使用.htaccess-> RewriteBase将$config['index_page']
更改$config['index_page'] = '';
在路线上,我已经这样改变了:
$route['default_controller'] = "site";
$route['(:any)'] = "site/$1";
而且它仅对站点控制器有效, 但是我的问题是我有另一个名为admin的控制器 ,当我尝试登录并使用redirect('admin / index')进行重定向时,出现404错误。
如何从站点控制器重定向到管理控制器?
如果要从(:any) => site
进行路由,则必须为管理控制器指定更高优先级的路由,以覆盖这些页面的路由。
$route['default_controller'] = "site";
$route['admin/(:any)'] = "admin/$1";
$route['(:any)'] = "site/$1";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.