Use hyphen(-) instead of slash(/) or underscore( _ ) in Routes Use hyphen(-) instead of slash(/) or underscore( _ ) in Routes codeigniter codeigniter

Use hyphen(-) instead of slash(/) or underscore( _ ) in Routes


You trying to create a dynamic routes which is not possible in codeigniter if you see the following flow chart of codeigniter you understand what i mean.

enter image description here

also you can see this chart in codeigniter official website

when you try to redirect or call some url it's work like this

enter image description here

Every request first goes to route there for you can't make it dynamic


Here is my solution, it is working for me, do like this.

$route['(:any)-Student-Search']  = "search";

then in your link button, hopefully in your view, href the link like this.

href="/<?php echo $row->classname; ?>-Student-Search"

the point is that not only you have to make your routes, also suffix it in your href link also the same way.