codeigniter allow special characters (like: ä, é, î, ø, ù) in uri codeigniter allow special characters (like: ä, é, î, ø, ù) in uri codeigniter codeigniter

codeigniter allow special characters (like: ä, é, î, ø, ù) in uri


You cannot use special characters directly in URL's.

RFC 1738 contains the following paragraph:

URLs are written only with the graphic printable characters of the US-ASCII coded character set.

A list of characters in the US-ASCII character set can be found at http://www.columbia.edu/kermit/ascii.html.

Additionally, certain characters within that set are also reserved for certain purposes for example the "=" and "&" characters. These characters (and characters not included in the US-ASCII character set) must be encoded with the use of a % sign followed by the character reference.

You can encode these values within codeigniter using urlencode(). For example if you redirected a user using redirect(urlencode(http://test.com/ä)), they would be redirected to http://test.com/%E4 which is a valid URL.

To decode this percent code back into a normal character for display on your page, simply use urldecode() for example:

echo 'The character is: ' . urldecode($this->uri->segment(2));

I hope this helps.

Dan


You can configure this in your application/config folder, in the config.php file:

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