Showing Posts From
Htaccess
-
Jeetendra Singh - 20 Oct, 2015
How to remove index.php from Codeigniter url
Here we will learn how to remove index.php from codeigniter url. Each of codeigniter constructed url contains the value index.php and excluding root url. No url cannot be run without index.php Assume a scenario , we have a website named www.myciportal.com Where we didn’t remove the index.php from url and i have a category with following details category name: techbuzz So by default it’s url will create like following default url : www.myciportal.com/index.php/techbuzz it will not run like this way www.myciportal.com/techbuzz For make this possible we have to work on config and htaccess both and steps are following to achieve this task If you are using mod_rewrite to remove the index.php in each url construct of codeigniter then you have to follow these steps: Step 1: In CI Project root Folder of your project create a .HTACCESS file and place following code in it RewriteEngine on RewriteBase /myprojectname RewriteRule ^(application|system|.svn) index.php/$1 [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php/$1 [QSA,L] Comments :: In above code myprojectname is passed with RewriteBase , which is the demo project name of our ci project,if you are running on main domain then Redirect base will be / only , or if you are running your project in any directory then you have to specify that name. Now Step 2: in your project >> application/config/config.php Replace following line $config['index_page'] = 'index.php'; with $config['index_page'] = ''; //removed the index.php after htaccess done Now you can run your Codeigniter project and you can see the index.php has been removed from every Controller Action