2014-09-23 63 views
0

参考:StackOverflow QuestionCodeIgniter删除类名不起作用

$route['default_controller'] = "homepage"; 
$route['(:any)'] = "handler/$1"; 
$route['404_override'] = ''; 

的网址,

http://localhost/sitename/homepage // Has to me mapped to Homepage controller

http://localhost/sitename/url-with-a-slug //URL with A-Z a-z 0-9 and - other than homepage has to be mapped to handler controller

现在,当$route['(:any)'] = "handler/$1";在routes.php文件中添加这两种中的网址无法正常工作。

但是没有行,homepagehandler/url-with-a-slug模式工作。

如何解决这个问题?

注意:控制器handler.php存在,当$route['(:any)'] = "handler/$1";行被删除时,http://localhost/handler/url-with-a-slug工作。

回答

0

尝试更改

$config['uri_protocol'] 

从配置/ config.php文件

+0

你能解释一下吗? – 2014-09-23 15:02:44

+0

尝试更改在配置文件下看到的其他选项。 – 2014-09-23 15:18:47

+0

在尝试可用选项时,所有重定向到主页。 – 2014-09-23 15:38:20

0

试试这个route,没有测试过它,因为我自己的计算机上没有我。但你有这个想法

$route['default_controller'] = "homepage"; //default 
$route['404_override'] = '';    //404 
$route['homepage'] = 'homepage';   // 0 
$route['sitename/homepage'] = 'homepage'; // 1 
$route['(:any)'] = "handler/$1";   // 2 

如果你有一个网址http://localhost/sitename/homepage1下进行处理,因为CI过程是在等级秩序的路线。因此上面的网址首先会在1之下处理,如果它不符合1路由,它将继续到2,直到找到最佳路由为止。

+0

即使没有'1',主页也能正常工作。但'2'不起作用。 – 2014-09-23 15:02:09