How to Remove index.php from URL in CodeIgniter

CodeIgniter uses the segment-based approach to design URLs human-friendly or seo-friendly. By default, the index.php file will be included with the URLs in CodeIgniter. But you can easily remove the index.php from the URL using .htaccess.

By default, all URLs in CodeIgniter looks like the below.

http://codexworld.com/index.php/tutorials/

By defining some simple rules in the .htaccess file, the index.php file can easily be removed from URL in CodeIgniter. To rewrite URLs using HTACCESS, mod_rewrite need to be enabled in your Apache server. Create a .htaccess file in the root directory of your project and place the following code in the .htaccess file.

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

Now, you can access URLs without index.php in CodeIgniter.

http://codexworld.com/tutorials/

6 Comments

  1. Jefri Said...
  2. Shadab Shaikh Said...
    • CodexWorld Said...
  3. Jessica Barnes Said...
  4. Saket Said...

Leave a reply

keyboard_double_arrow_up