Php 需要在CodeIgniter中使用路由的帮助吗

Php 需要在CodeIgniter中使用路由的帮助吗,php,codeigniter,Php,Codeigniter,我对codeiIgniter中的路由是如何工作的有点困惑。我已经设置了以下路线 $route['myfirstest'] = 'Blogs'; 然后,我在application/controllers目录下设置了一个名为blogs.php的php文件 当我运行以下URL时 /code_igniter/index.php/myfirstest/hello/hello 我收到一条404信息 但是,当我运行以下URL时 /code_igniter/index.php/blogs/hello/hel

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

$route['myfirstest'] = 'Blogs';
然后,我在application/controllers目录下设置了一个名为blogs.php的php文件

当我运行以下URL时

/code_igniter/index.php/myfirstest/hello/hello
我收到一条404信息

但是,当我运行以下URL时

/code_igniter/index.php/blogs/hello/hello
它可以找到


有人能帮我弄清楚这件事吗也许我没有弄清楚整个路线

我想这对你有用

$route['myfirstest'] = 'Blogs';
$route['myfirstest/(:any)'] = "Blogs/$1"
这对你也有用,但我不认为这是你真正的目的

$route['myfirstest/hello/hello'] = "Blogs/hello/hello";
如果您想要hello函数中的任何值,可以这样编写

$route['myfirstest/hello/(:any)'] = "Blogs/hello/$1";
记住,对于第二个和第三个解决方案,您还需要编写

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

您还需要添加这个$route['myfirstest/:any']=Blogs/$1;