本文介绍了如何路由cutom URL到自定义控制器在CodeIgniter?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为 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 user user_detail($username)
Now when i need to show user data for example for userName mike
I call this URL
http://www.example.com/user/user_detail/mike

My 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-17 04:44