简体   繁体   English

CodeIgniter中的动态URL?

[英]Dynamic URLs in CodeIgniter?

如何在CodeIgniter中动态获取/ user / bob user / martin等URL?

您需要在application / config / routes.php中为控制器设置自定义路由,例如

$route['user/(:any)'] = "user/user_controller_method/$1";

you should use the 你应该使用

$route['user/(:any)'] = "user/user_controller_method/$1";

as James suggested, and then define the funcion on the user controller: 正如James建议的那样,然后在用户控制器上定义功能:

function user_controller_method($username) {
   // ... $username should be the url param
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM