How to remove index.php from url in codeigniter ?

QuestionsHow to remove index.php from url in codeigniter ?
webdeveloper asked 4 years ago

I want code for removing index.php from url in codeigniter.

2 Answers
Web Guru Staff answered 4 years ago

Step 1 –
Add this code in root of your htaccess file.

RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond $1 !^(index\.php|timthumb\.php|images|robots\.txt|css|docs|js|system)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Step 2 –

Remove index.php from config.php file

Harry answered 3 years ago

Put below code in your .htaccess file in your root folder

RewriteEngine on
RewriteCond $1 !^(index\.php|resources|robots\.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

And remove index.php in config.php file