dtl85148 2013-07-03 10:41
浏览 43

codeigniter url中的括号问题

Few of my project urls contains the parenthesis and it is a codeigniter project. Unfortunately I cant remove them. So I am writing following rules in my route.php of config folder:

$route['abc-(def)'] = 'locations/index/12492';
$route['abc-%28def%29'] = 'locations/index/12492';
$route['404_override'] = 'home/pagenotfoundhandler';

So when I am trying to access URL http://mydomain.com/abc-(def) or http://mydomain.com/abc-%28def%29 it takes me to home/pagenotfoundhandler, while it should take me to location controller and index method. Please suggest how to deal with parenthesis in codeigniter.

  • 写回答

2条回答 默认 最新

  • dongyan7172 2013-07-03 10:44
    关注

    The parentheses are a part of the regex pattern, so try escaping them if you want to use them as ascii characters like this:

    $route['abc-\(def\)'] = 'locations/index/12492';
    

    And one more place to look:

    There should be a allowed uri characters setting in config.php for your codeigniter system. check there if parentheses are allowed.

    Alternatively, you can disable $config["csrf_protection"] to skip url xss cleaning.

    评论

报告相同问题?

悬赏问题

  • ¥15 对于知识的学以致用的解释
  • ¥50 三种调度算法报错 有实例
  • ¥15 关于#python#的问题,请各位专家解答!
  • ¥200 询问:python实现大地主题正反算的程序设计,有偿
  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败