问题描述
我有一个名为 User
的PHP CodeIgniter控制器,并且有一个方法来获取用户 user_detail($ username)
现在当我需要显示用户数据例如userName mike
我叫这个URL
我的目标
如何使用户数据可通过下一个网址访问
或/和
您必须阅读这个从codeigniter的官方文档。它涵盖了所有相关的事情到路由URL很容易。所有路线必须通过文件配置:
application / config / routes.php
可能是这样的:
$ route ['user /(:any)'] =user / user_detail / $ 1;
I have a PHP CodeIgniter Controller with name
User
and have a method that get details of useruser_detail($username)
Now when i need to show user data for example for userNamemike
I call this URL
http://www.example.com/user/user_detail/mikeMy target
How to make user data accessible by next URLs
http://www.example.com/user/mike
or / and
http://www.example.com/mike解决方案You have to read the this page from the official documentation of codeigniter. It covers all related things to Routing URLs easily. All routes must be configured via the file:
application/config/routes.php
It could be something like this :
$route['user/(:any)'] = "user/user_detail/$1";
这篇关于如何路由cutom URL到自定义控制器在CodeIgniter?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!