How To Remove index.php from CodeIgniter URL Path

Open config.php and do the following replaces

$config['index_page'] = "index.php"

to

$config['index_page'] = ""

In some cases, the default setting for uri_protocol does not work properly. Just replace

$config['uri_protocol'] ="AUTO"

by

$config['uri_protocol'] = "REQUEST_URI"

.htaccess

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

Note: .htaccess code varies depending on the hosting server. In some hosting servers (e.g.: Godaddy) need to use an extra? in the last line of the above code. The following line will be replaced with the last line in applicable case:

// Replace last .htaccess line with this line
RewriteRule ^(.*)$ index.php?/$1 [L,QSA] 


Tagged:
Sign In or Register to comment.