douganggu4392 2014-02-26 17:57
浏览 51
已采纳

Codeigniter动态变量路由

I am looking to dynamically re-route urls based on a parameter within the uri segment. For example if I have the following url:

domain.com/account/message/action/view

How could I go about creating a route that checked to see if the uri contained "action" and if so re-route to the value of the function + '_' + value of action?

domain.com/account/message_view

I've been reading through the routes documentation provided by ellislab and am still not quite sure how to go about doing something like this or if it would be better to use server rewrite rule? Any information greatly appreciated!

  • 写回答

1条回答 默认 最新

  • dongshi7433 2014-02-26 18:16
    关注

    You would likely want to use the regular expressions availability in routes. Something along the lines of:

    $route['([a-z]+)/action/([a-z]+)'] = "$1_$2";
    

    Of course, that may not be exactly what you are looking for, but it should get you started.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 questasim仿真报错
  • ¥15 寻找电脑攻防的导师,有问题请教一下。
  • ¥20 微信同是win11,我的电脑安装不了pageoffice,一直无法打开
  • ¥15 这个界面我通过postman请求不到,但是通过浏览器可以正常访问
  • ¥15 动态规划算法实现背包问题
  • ¥15 wpf程序使用过程中异常奔溃
  • ¥15 多目标优化算法在与其他算法数据对比结果判断
  • ¥15 CPTN和EAST,主干网络是VGG16,请问在ICDAR2015数据集上训练之后,CPTN和EAST模型的大小为多少
  • ¥15 按颜色进行点云分割-python
  • ¥15 Matlab如何实现汽车变道切入场景的批量仿真