Remove controller name from the URL in CodeIgniter

Example URL:

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 ,

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 you can mention as many as controller function 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 :

.htaccess mod_rewrite for CodeIgniter

<IfModule mod_rewrite.c>
  RewriteEngine On
  # !IMPORTANT! Set your RewriteBase here and don't forget trailing and leading
  #  slashes.
  # If your page resides at
  # then use
  # RewriteBase /mypage/test1/
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L]

<IfModule !mod_rewrite.c>
  # If we don't have mod_rewrite installed, all 404's
  # can be sent to index.php, and everything works as normal.

  ErrorDocument 404 /index.php