[英]Need help using routes in CodeIgniter
I am little bit confused on how routes work in codeiIgniter. 我对codeiIgniter中的路由工作方式有些困惑。 I have set up this following route 我设置了以下路线
$route['myfirstest'] = 'Blogs';
I then set up a php file called blogs.php under the application/controllers directory 然后,我在application / controllers目录下设置了一个名为blogs.php的php文件。
When I run the following URL 当我运行以下网址时
/code_igniter/index.php/myfirstest/hello/hello
I get a 404 message 我收到404讯息
However when I run this following URL 但是,当我运行以下URL时
/code_igniter/index.php/blogs/hello/hello
It works find 它可以找到
Can anyone please help me figure this out..Maybe I am not getting the whole route thing correctly.. 任何人都可以帮我解决这个问题。也许我没有正确获得整个路线。
I think this will work for you 我想这对你有用
$route['myfirstest'] = 'Blogs';
$route['myfirstest/(:any)'] = "Blogs/$1"
This will also work for you.But I don't think this is your real purpose. 这也将为您工作。但我认为这不是您的真正目的。
$route['myfirstest/hello/hello'] = "Blogs/hello/hello";
If you want any value inside hello function you can write this way 如果您想在hello函数中输入任何值,可以这样编写
$route['myfirstest/hello/(:any)'] = "Blogs/hello/$1";
Remember for 2nd and 3rd solution you also need to write 请记住,对于第二和第三解决方案,您还需要编写
$route['myfirstest'] = 'Blogs';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.