2013-03-18 154 views
0

在CodeIgniter中存在路由问题。URI路由Codeigniter

这里是我的routes.php文件

$route['default_controller'] = "site/site/index/$1"; 
$route['404_override'] = ''; 
$route['admin'] = 'admin/index'; 

我使用模块化系统,我的文件夹格式为:

folder

在侧模块>网站>控制器> site.php我有以下获取每个进入cms的路径,但问题是当我导航到localhost/my_site /它显示页面,但有错误,所以如果我把以下路线:$ route ['site /(:any)'] ='site/site/index/$ 1';它然后工作,并显示所有的网页,但显然我不想这样,我想它知道,主页设置。或者可以通过htaccess DirectoryIndex完成?

如果这没有意义,或者你不能理解我的意思是给我一个呼喊,我会尝试解释更多细节,但这是关于它的问题。

+0

模块的site.php>网站>控制器是如下所示:http://pastebin.com/x5eAtb4d – 2013-03-18 12:58:02

回答

1

我认为它是因为你默认控制器需要一个参数,但你是不是传递一个

$route['default_controller'] = "site/site/index/$1"; 

我觉得应该是

$route['default_controller'] = "site/site/index"; 
+0

是的,我现在有,但我想第一次导航到http:// localhost/my_site我想主页显示,而不是我必须去http:// localhost/my_site/site/home这显然是我不想要的,怎么能绕过这个? – 2013-03-18 14:34:43

+0

尝试$ route ['default_controller'] =“site/home”;或$ route ['default_controller'] =“site/site/home”; – Pattle 2013-03-18 15:27:17

+0

但我没有函数/方法在它的只是一个索引方法获取$路径像这样。公共函数索引($ path =''){ \t \t \t \t $ page = $ this-> wc_main-> getPagePath($ path); \t \t \t \t \t \t $这个 - >前置式>设置( '页',$页); \t \t \t $ this-> front-> set('title',ucfirst($ page ['title'])); \t \t $ this-> front-> buffer('content','site/index'); \t \t $ this-> front-> render(); \t \t \t} – 2013-03-18 15:34:36