CodeIgniter Forums
Problems with spaces and in the URL - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Problems with spaces and in the URL (/thread-24698.html)



Problems with spaces and in the URL - El Forum - 11-17-2009

[eluser]uk81[/eluser]
Hi Guys.

I have a little problem and want to figure out if this is a codeigniter problem.

I have programmed an app.
I have services in a database and want to access a service (viewing details of it) by passing the service name via url (as an normal codeigniter paramter) like:
Code:
http://my.domain.com/index.php/controller/function/My Service Name

Normally I want to put the Service Name url-encoded like:
Code:
http://my.domain.com/index.php/controller/function/My% 20Service% 20Name

For this I use the php function rawurlencode:
http://de.php.net/manual/de/function.rawurlencode.php

But what I get from codeigniter (or apache, I donĀ“t really know) is a url like above without encoded spaces:
Code:
http://my.domain.com/index.php/controller/function/My Service Name

When I type in a URL with "% 20" for a space I get the site and in the URL I see it not encoded.
I never saw this before when working with codeigniter.
So I want to ask you if you have also something of these problems and if this is a codeigniter behaviour (and when: can I change it and where?) or the problems source somewhere else?

Thanks for your suggestions! Smile

Greetz
/Ulf

[edit]
Sorry I forgot to put a space after each '%' because the board softwaer converts "% 20" (without space) into a normal space. Now you can see my problem. Smile


Problems with spaces and in the URL - El Forum - 11-17-2009

[eluser]umefarooq[/eluser]
for your problem there are two solutions if you are making database driven menu then replace space with url helper function - or _ like
Code:
url_title($title);

when getting parameter

srt_replace('_',' ',$title);
here you can see doc http://ellislab.com/codeigniter/user-guide/helpers/url_helper.html

second create column name seo_url in your table and save title in table with same way how your are making in menu then you can directly use that column value in url and take that parameter for query.
Code:
url_title($title);