Remove index.php from url in codeigniter

Remove index.php from url in codeigniter

index.php is default the framework routes in CodeIgniter. In this following code we will show you how to remove index.php from url using .htaccess file.

Remove index.php from url in codeigniter
Remove index.php from url in codeigniter
http://onlinecode/index.php/remove-index/
to 
http://onlinecode/remove-index/

http://127.0.0.1/codeigniter_projct/index.php/remove-index/
to
http://127.0.0.1/codeigniter_projct/remove-index/

Follow this step for index.php remove form url.

Steps To index.php Remove :-

Step :- 1) Go to application/config and open the file config.php.
Find and Replace the following code in config.php file.

//  Find following code
$config['index_page'] = "index.php";

// And Remove index.php
$config['index_page'] = "";

Step :- 2) Go to your CodeIgniter directory(root directory) and create/add .htaccess file.

Path of  directory :-

codeigniter_projct/
.htaccess <--- create/add file hear(on root)
index.php
application/
assets/
system/

Step :- 3) Add following code in .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

Step :- 4) In some cases of default setting does not work properly for uri_protocol . To resolve this issue Go to application/config and open the file config.php.Find and Replace the following code in config.php file:

//  Find the following code
$config['uri_protocol'] = "AUTO"; // AUTO to REQUEST_URI
//  Replace it as
$config['uri_protocol'] = "REQUEST_URI"; // AUTO to REQUEST_URI

Leave a Comment

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

  +  7  =  14

We accept paid advance and paid guest Posting on our Site : Contact US