July 22, 2018
How to Remove index.php from URL in CodeIgniter
How to Remove index.php from URL in CodeIgniter
In CodeIgniter we can design URLs human-friendly or seo-friendly.
By default in codeigniter, the index.php is added with the URLs. But we remove the index.php from the URL using .htaccess.
Step 1 :
Goto “/application/config/config.php”. You will find there below code.
1 2 3 4 |
$config['index_page'] = 'index.php'; //Replace above code with below code $config['index_page'] = ''; |
Step 2:
Add following rules in your .htaccess file on root directory.
1 2 3 4 |
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^(.*)$ index.php?/$1 [L] |
Now the codeigniter application works without index.php
If you face still there is an issue then you need to change one more configuration in config.php file.You need to find below code
1 2 3 |
$config['uri_protocol'] = 'AUTO'; //Replace above code with below code $config['uri_protocol'] = 'REQUEST_URI'; |