Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeigniter route problem

result I want :

greeting/102/steve =>  greeting/index/102/steve

in greeting.php :

function index($order,$name)
{
    echo "order: $order , name : $name ! ";
}    

in route.php :

$route['greeting/(:num)/(:any)'] = "greeting/index/$1/$2";    

result I get :

order : , name : steve !
like image 536
soredive Avatar asked Sep 09 '26 21:09

soredive


1 Answers

Actually, it's right to use double quotes. It's even indicated like this in the manual (beside having done it a hundred times), so I don't see the problem @cwallenpool is pointing out.
Your routing looks fine, be sure it is called after the reserved routes

$route['default_controller'] = "welcome";
$route['404_override'] = '';
$route['greeting/(:num)/(:any)'] = "greeting/index/$1/$2";

.
I suggest you to try using $this->uri->rsegment(n) (info on user guide here) to catch the rerouted uri segment that's causing you trouble. (similar to $this->uri->segment(n) but designed specifically for rerouted URIs)

You can also try changing the $config['uri_protocol'] from AUTO to PATH_INFO (or one of the other alternatives) and see if the problem doesn't sit there. Remember also to delete the 'index.php' part in $config['index_page'] if you're using htaccess to delete the index.php from you URL.

like image 108
Damien Pirsy Avatar answered Sep 12 '26 11:09

Damien Pirsy



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!