如何在CodeIgniter URL中允许双引号(引号)

时间:2014-02-13 20:08:28

标签: php .htaccess codeigniter

CodeIgniter的新手,但我尝试了一些方法:

Remove Characters from URL with htaccess / URL array codeigniter / CodeIgniter Disallowed Key Characters

当使用包含双引号的网址时,我一直收到同样的错误:

Disallowed Key Characters.

请有人告诉我我做错了什么。这一开始看起来很简单,但显然我不理解。

2 个答案:

答案 0 :(得分:0)

打开CI目录中的config文件夹,查找以下行:

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

如果你想使用双引号,请在那里添加。

接下来转到 codeigniter-> core-> input.php

找到:_clean_input_keys($str) function

附加以下一行:exit('Disallowed Key Characters.'.$str);

现在您应该看到导致错误的行并相应地修复它。

答案 1 :(得分:0)

这似乎对我有用。我在咨询了几个来源后发现,有各种方法可以解决这个问题。我修改了html / system / core / Input.php中的这一部分以匹配以下内容。我插入了一个PHP函数,用于替换URL字符串的“with”实例。完成了工作。

 /**
  * Clean Keys
  *
  * This is a helper function. To prevent malicious users
  * from trying to exploit keys we make sure that keys are
  * only named with alpha-numeric text and a few other items.
  *
  * @access private
  * @param  string
  * @return string
  */
  function _clean_input_keys($str)
  {
     $str = str_replace('"','',$str);
    if ( ! preg_match("/^[a-z0-9:_\/-]+$/i", $str))
    {
      exit('Disallowed Key Characters...');
    }

    // Clean UTF-8 if supported
    if (UTF8_ENABLED === TRUE)
    {
      $str = $this->uni->clean_string($str);
    }

    return $str;
  }
相关问题