Reputation: 11
Anyone know of a way to prevent codeigniter stopping on a slash when parsing arguments?
example.com/code/master/foo/bar
Where code
and master
would be arguments 1 and 2, and then the rest as argument 3.
Update: Part of the routing code separates segments by slashes, so I don't think it's possible that way. I did find a work around by using uri->segments.
Upvotes: 1
Views: 1738
Reputation: 2768
OK I know this is old now, but here's how you do it with CodeIgniter 3:
// Match everything including slashes
$route['code/master/(.+)'] = 'code/master/$1';
Then in your controller you can get an unlimited number of parameters like this:
$trail = func_get_args();
Upvotes: 1
Reputation: 770
There is no way to do this. According to system/libraries/Router.php
, the first thing the Router does is split the request based on slashes. Only after it is split does it start looking at the contents using regular expressions.
You could try extending the Router class, but my recommendation is to not use slashes for parameters whenever possible.
Upvotes: 1
Reputation: 8349
Create a custom route in application/config/routes.php
.
$route['code/master/(:any)'] = 'code/master/$1';
Upvotes: 0