diarmuid
diarmuid

Reputation: 25

Codeigniter URI routing variable encoding

I am using the following routing rule in my codeigniter project's routes.php file:

$route['manage/(:any)'] = "manage/item_lookup/$1";

this redirects anything after manage in the url to the item_lookup function as a variable. Everything after the manage bit is a text string from a database which is then urlencoded i.e.

the page "some page title" becomes "manage/some+page+title"

However the variable passed to the item_lookup function by codeigniter is "some_page_title". The spaces are getting encoded as underscores instead of plus signs.

is there some way to force php to urlencode spaces to underscores or tell codeigniter to use plus signs?

Thanks, Diarmuid.

Upvotes: 1

Views: 964

Answers (1)

Phil Sturgeon
Phil Sturgeon

Reputation: 30766

If you put spaces in your URL's they will be converted. Use the url_title() to create proper URL slugs, then lookup your page based on that slug.

Upvotes: 3

Related Questions