Remove Controller name
This tutorial helps to you for remove controller name from URL in your Codeigniter project.
First of all you need to create a .htaccess file in your Codeigniter project folder and give some code that’s are write in below
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [L] <Files "index.php"> AcceptPathInfo On </Files>
Remove Controller name from URL follow the steps:-
You need to go to the routes.php and set a URL link and define a function name under a Controller Class name, like this
Project Name -> Application -> Config-> Routes.php
$route['home']='Welcome/home_page';
Then you need to create a Controller Page and set Class name which you are define in Routes Page. Go to the Controller Page and call the function name which defines in Routes Page under Controller Class name. I already use a Controller page that name is welcome.php and Class name is Welcome.
Now you have to write page view code. That’s like
<?php class Welcome extends CI_Controller { public function home_page (){ $this->load->view('home'); } }
Type in your URL localhost/Project Name/home or localhost/codeigniter/home
If any problem from this tutorial you can comment us.