Search code examples
phpcodeignitercodeigniter-routing

URI segment as parameter to function: passing commas,+,date formats as URI segments allowed?


Can you pass commas or + symbols or data in date - time format as parameters in URI segment in codeigniter? like calling through ajax a url like : controller/function/argument1/argument2

Now can this argument 1 contain characters like +,(,),comma when called from front end? Seems otherwise.I tried passing an address variable to the function through the URI segment, however the + signs, commas present in the address generate an error. The same happened with date format that is passed from frontend. Is this a restriction or is there a work-around?


Solution

  • If you check the config.php file in your application/config folder you can find the following:

    |--------------------------------------------------------------------------
    | Allowed URL Characters
    |--------------------------------------------------------------------------
    |
    | This lets you specify with a regular expression which characters are permitted
    | within your URLs.  When someone tries to submit a URL with disallowed
    | characters they will get a warning message.
    |
    | As a security measure you are STRONGLY encouraged to restrict URLs to
    | as few characters as possible.  By default only these are allowed: a-z 0-9~%.:_-
    |
    | Leave blank to allow all characters -- but only if you are insane.
    |
    | DO NOT CHANGE THIS UNLESS YOU FULLY UNDERSTAND THE REPERCUSSIONS!!
    |
    */
    $config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';
    

    So, basically, you can change it to accept whatever symbol you want, but I really don't know what type of reason that lets you pass other than the above allowed symbols in your uri.