Easy way to add case insensitive routing in CakePHP 2

安稳与你 提交于 2019-12-11 12:07:30

问题


Router::connect('/(?i:about)', array('controller' => 'pages', 'action'=>'display', 'about'));

used to work in CakePHP 1.2 but it seems to not be working in CakePHP 2.x

The only other solution that I see is to use the options to set a regular expression that will match against the a flag in the rout, but it seems rather convoluted for something so simple:

Router::connect('/:aboutFlag', array('controller' => 'pages', 'action'=>'display', 'about'),array("aboutFlag"=>"[aA]bout"));

Is there an easier solution more akin to how it was done in cake 1.2?


回答1:


Router::connect('/:aboutFlag', array('controller' => 'pages', 'action'=>'display', 'about'),array("aboutFlag"=>"(?i:about)"));

This stems from the answer posted here



来源:https://stackoverflow.com/questions/11690966/easy-way-to-add-case-insensitive-routing-in-cakephp-2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!