Remove controller name from the URL in CodeIgniter

Example URL: http://www.raisul.net/controller/function/parameter

here “controller” is your controller name

“function” is controller function

“parameter” is parameter of pages function.

Now if we remove controller name from url,it should work , http://www.raisul.net/function/parameter

Open application/config/routes.php file ,and modify the entire code like this


$default_controller = "controller"; // default controller name
$route['default_controller'] = $default_controller;

// here i removed controller name from url
$controller_exceptions = array(“function”); // here function is controller function name.here you can mention as many as controller function names.so that we can exclude controller name from the url

foreach($controller_exceptions as $v) {
$route[$v] = “$default_controller/”.$v;
$route[$v.”/(.*)”] = “$default_controller/”.$v.’/$1′;
}
now run your project url like : http://www.raisul.net/function/parameter

2 thoughts on “Remove controller name from the URL in CodeIgniter”

Leave a Reply to mollika Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>