codeigniter url 中的括号问题 [英] Parenthesis issue in codeigniter url

查看:47
本文介绍了codeigniter url 中的括号问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目 url 中很少包含括号,它是一个 codeigniter 项目.不幸的是我不能删除它们.所以我在 config 文件夹的 route.php 中写了以下规则:

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';

所以当我尝试访问 URL http://mydomain.com/abc-(def)http://mydomain.com/abc-%28def%29 需要我到 home/pagenotfoundhandler,而它应该带我到位置控制器和索引方法.请建议如何处理codeigniter中的括号.

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.

推荐答案

括号是正则表达式模式的一部分,因此如果您想将它们用作 ascii 字符,请尝试转义它们,如下所示:

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:

在 config.php 中应该为您的 codeigniter 系统设置允许的 uri 字符.检查那里是否允许使用括号.

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

或者,您可以禁用 $config["csrf_protection"] 以跳过 url xss 清理.

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

这篇关于codeigniter url 中的括号问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆