【问题标题】:Codeigniter not allowing a specific & symbol in URLCodeigniter 不允许在 URL 中使用特定的 & 符号
【发布时间】:2016-10-05 20:39:51
【问题描述】:

以下 URl 会导致错误提示:“您提交的 URI 包含不允许的字符。”

http://example.com/index.php?/Paypal/success&tx=8T317791V7961045T&st=Completed&amt=20%2e00&cc=USD&cm=&item_number=

但是,如果我只是将“成功”后的 & 符号更改为 ?如下所示,尽管 URL 中还有其他 & 符号,但一切正常。这里发生了什么?

http://example.com/index.php?/Paypal/success?tx=8T317791V7961045T&st=Completed&amt=20%2e00&cc=USD&cm=&item_number=

如何才能使“成功”后的 & 符号被接受?我尝试在 Config.php 中执行以下操作,但没有成功:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-\&';

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-&';

当我尝试这个时,我得到了 404 Page Not Found 错误:

$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-?=&';

【问题讨论】:

  • 你试过把$config['uri_protocol'] = 'REQUEST_URI';改成$config['uri_protocol'] = 'QUERY_STRING';
  • 是的,它已经是'QUERY_STRING';

标签: php codeigniter paypal


【解决方案1】:

我认为“/Paypal/success”是一个控制器 + 函数,以及将查询字符串放入 codeigniter 的正确方法 $config['index_page'] = 'index.php'; 是:

http://example.com/index.php/Paypal/success?tx=8T317791V7961045T&st=Completed&amt=20%2e00&cc=USD&cm=&item_number=

【讨论】:

    【解决方案2】:

    codeigniter 中的 url 是 urldecoded,因此 %27 转换为 ' ,它不在允许的字符列表中,因此触发了错误。因此,您需要允许字符一旦解码。换句话说,当 codeigniter 看到你 %27 时,它已经被解码为 '。

    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_()@&\-!';
    

    【讨论】:

    • 我不确定你在说什么 Ashu,因为据我所知,链接中没有 %27 或 '。不过,我已经尝试过您的解决方案,但结果是一样的。 :(
    • 试试这个 $config['permitted_uri_chars'] = 'a-z 0-9~%.:_+&-';
    猜你喜欢
    • 2012-03-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-05
    • 2017-10-06
    • 2014-03-12
    • 2013-06-16
    • 2011-05-09
    相关资源
    最近更新 更多