在CodeIgniter中使用路由需要帮助

时间:2015-01-11 18:41:43

标签: php codeigniter

我对codeiIgniter中的路由如何工作有点困惑。我已经设置了以下路线

$route['myfirstest'] = 'Blogs';

然后我在application / controllers目录下设置了一个名为blogs.php的php文件

当我运行以下网址

/code_igniter/index.php/myfirstest/hello/hello

我收到了404消息

但是,当我运行以下URL

/code_igniter/index.php/blogs/hello/hello

找到工作

任何人都可以帮我解决这个问题。也许我没有正确地得到整条路线......

1 个答案:

答案 0 :(得分:0)

我认为这对你有用

$route['myfirstest'] = 'Blogs';
$route['myfirstest/(:any)'] = "Blogs/$1"

这对你也有用。但我不认为这是你的真正目的。

$route['myfirstest/hello/hello'] = "Blogs/hello/hello";

如果你想在hello函数中有任何值,你可以这样写

$route['myfirstest/hello/(:any)'] = "Blogs/hello/$1";

请记住第2和第3个解决方案,您还需要编写

$route['myfirstest'] = 'Blogs';
相关问题