How to Remove index.php from codeigniter
In this article you will learn how to remove index.php from codeigniter project URL using .htaccess file. htaccess means Hypertext Access, htaccess is a configuration file that controls the directory “.htaccess”.
So in this article we are working on how to remove index.php from codeigniter url, So below are complete method of removing index.php.
Below are steps To Remove index.php from codeigniter through .htaccess:-
Step:-1 Open file config.php in application/config path. Find the below code in config.php and replace.
// Find this code
$config['index_page'] = "index.php"
// And Remove index.php
$config['index_page'] = ""
Step:-2 Go to your CodeIgniter project root folder and create .htaccess file.
Path:
Your_Project_folder/
application/
assets/
system/
user_guide/
.htaccess <--------- this file
index.php
license.txt
Step:-3 Copy and paste below 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 Change below code as it is
// Find the below code
$config['uri_protocol'] = "AUTO"
// Replace it as
$config['uri_protocol'] = "REQUEST_URI"
You must be logged in to post a comment.