【问题标题】:CodeIgniter - Maintain complex URL routingCodeIgniter - 维护复杂的 URL 路由
【发布时间】:2014-04-21 10:34:15
【问题描述】:

我想在路由时维护一个复杂的 URL 结构。我无法为以下要求编写路由。

如果URL带有http://localhost/api/cals/func/id我想将它路由到http://localhost/api/cals/func/id,否则我想将URL路由到http://localhost/home/

我试过了,但它并不是在所有用例中都有效。

$route['api/(:any)'] = 'api/(:any)';

$route['(:any)'] = 'home/index/';

为什么会这样?

【问题讨论】:

    标签: php angularjs codeigniter routing


    【解决方案1】:

    这可能会对您有所帮助; 你必须使用$1

    $route['default_controller'] = 'home/index/';
    
    $route['api/(:any)'] = 'api/$1';
    
    $route['(:any)'] = 'home/index/';
    

    【讨论】:

      猜你喜欢
      • 2013-11-11
      • 2016-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多