Remove index.php in CodeIgniter

Edit the file system/application/config/config.php. Search for

$config[‘index_page’] = “index.php”;

And change to

$config[‘index_page’] = “”;

Create an .htaccess and place it in the root directory.

# Turn on URL rewriting
RewriteEngine On

# Protect application and system files from being viewed
RewriteRule ^(system) – [F,L]

# Allow any files or directories that exist to be displayed directly
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

# Rewrite all other URLs to index.php/URL
RewriteRule .* index.php/$0 [PT,L]

Leave a Reply

Your email address will not be published. Required fields are marked *