2014-02-13 33 views
0

新來的CodeIgniter雙引號(​​quoation痕跡),但我已經嘗試了幾種方法:如何讓CI中的URL

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

我不斷收到同樣的錯誤時,使用包含雙引號的網址:

Disallowed Key Characters. 

請別人告訴我我做錯了什麼。這起初看起來很簡單,但顯然我並不瞭解。

+1

你爲什麼會想這樣做,這是一個安全漏洞,反正用urlencode可能會派上用場:。?。 http://www.php.net/urlencode –

+0

這是一個電子商務網站,它擁有大量流量,其流量來源之一 - Google購物 - 正在發送一串連接到我們傳統網址的變量,我假設這些網址是一些 – sparecycle

回答

0

在CI目錄查找的行打開config文件夾:

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

如果你想使用雙引號添加它。

下次再去codeigniter->核心 - > input.php

發現:_clean_input_keys($str) function

追加這一行:exit('Disallowed Key Characters.'.$str);

現在你應該看到這是造成你的錯誤的行及相應地修復它。

+0

我認爲使用/application/code/MY_Input.php擴展輸入類比編輯CI核 –

+0

更好,我無法得到以上解決我的問題,但仍然感謝你愛德華。 – sparecycle

0

這是什麼似乎爲我工作。我在諮詢了幾個來源之後意識到有各種方法可以解決這個問題。我修改了html/system/core/Input.php中的這個部分以匹配以下內容。我插一個PHP函數,用於替換「與」的情況下,對URL字符串做了工作

/** 
    * 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; 
    }