Welcome Guest, Not a member yet? Register   Sign In
Special characters in the URI?
#1

[eluser]ryeguy[/eluser]
Is there a way to encode special characters in the URI without enabling them all in the config? I tried using urlencode(), but the percent signs mess everything up and for some reason the server spits out:
Code:
Bad Request
Your browser sent a request that this server could not understand.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

I guess a solution would be to step through the string before it is put in the uri and encode the special characters myself. I could look at each char, see if it is a special character, and if it is, replace it with _asc(character)_. That would be ugly, increase the length of my uri, and it makes me feel dirty. Please don't make me do this. Smile
#2

[eluser]JoostV[/eluser]
CI has a function url_title(), in the uri helper that does this for you.
Code:
$dirty_uri = 'This IS %% a ?>:freaky uri';

$this->load->helper('url');
$clean_uri = url_title($dirty_uri);

http://ellislab.com/codeigniter/user-gui...elper.html




Theme © iAndrew 2016 - Forum software by © MyBB