donglian1982 2012-11-09 13:04
浏览 7
已采纳

在li3中是否有可能不区分大小写的路由?

I would like to create a Route at Lithium, which matches

  • /abc
  • /abC
  • /aBc
  • and so on

So far i have something like this:

Router::connect('/abc', array('Example::test'));

Is there a possibility to change it to something uncase sensitive.

Thanks for your help, i couldn't find a thing in the docs.

  • 写回答

2条回答 默认 最新

  • doujiazong0322 2012-11-09 16:07
    关注

    You should be able to do it like this:

    Router::connect('/{:dummy:[aA][bB][cC]}', array('Example::test'));
    

    Edit: There is a nicer way to do it as well by creating the Route object by your self

    Router::connect(new Route(array(
            'pattern' => '@^/ab?$@i',
            'params' => array('controller' => 'example', 'action' => 'test'),
            'options' => array('compile' => false, 'wrap' => false)
    )));
    

    If i brake out the pattern above '@^/ab?$@i'

    • @ == start of regex
    • ^ == start of line
    • /ab == look for "/ab
    • ? == optional trailing slash
    • $ == end of line
    • @ == end of regex
    • i == make it case insensitive

    And you can find more information here: http://li3.me/docs/lithium/net/http/Route

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持