how remove index php from url in codeigniter using htaccess

Hi there,

I am currently using codeIgniter 2.1.4,  

I am aware that you can remove the 'index.php' in the url with a mod rewrite using the htaccess file.

However I do not know how to go about doing it.

Can anyone offer a solutions.

I have attached the project that I am working on, so please take a look.

Kind Regards
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

Loganathan NatarajanConnect With a Mentor LAMP DeveloperCommented:
Yes, you can easily remove index.php from your app.  Do you use linux or windows?

For that you need to enable "RewriteEngine on"  & create the below instrcution way of .htaccess file

RewriteEngine On

# Put your installation directory here:
# If your URL is, use /
# If your URL is, use /site_folder/

#RewriteBase /staging/

# Do not enable rewriting for files or directories that exist
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# For reuests that are not actual files or directories,
# Rewrite to index.php/URL
RewriteRule ^(.*)$ index.php/$1 [PT,L] 

Open in new window


1.Create your htaccess file
2.Set $config[‘index_page’] to an empty (config.php)
3.string Set $config['uri_protocol'] = 'REQUEST_URI'; (config.php)

htaccess file:

Options -Indexes
Options +FollowSymLinks

RewriteEngine On
RewriteBase /

#Removes access to the system folder by users.
#Additionally this will allow you to create a System.php controller,

RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ index.php?/$1 [L]

#When your application folder isn't in the system folder

RewriteCond %{REQUEST_URI} ^application.*
RewriteRule ^(.*)$ /index.php?/$1 [L]

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [L]

Hope this will help you.

For more info:

Shobin Markose.
smaids123Author Commented:
Thanks a lot
Now I can get on with my project :)
Loganathan NatarajanLAMP DeveloperCommented:
I hope you have followed to remove in config.php  , $config[‘index_page’] to an empty (config.php)
All Courses

From novice to tech pro — start learning today.