[英]Need help using routes in 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
它可以找到
任何人都可以帮我解决这个问题。也许我没有正确获得整个路线。
我想这对你有用
$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';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.