Removing index.php from url - CI

Guide on removing the index.php from the URL in CodeIgniter website.

Removing "index.php" from the URL makes the website nice and also search engines like it. It is easy to remove the index.php from the URL in CodeIgniter website. Here are the three little steps.

  1. Enable the apache ModRewrite module. If you are using wamp server you do it by using the menu in the task bar icon. Most of the hosting providers enable this by default or this can be enabled in the cpanel of the hosting account.
  2. Open config.php from system/application/config directory and replace $config['index_page'] = “index.php” by $config['index_page'] =''
  3. Now create the .htaccess file in your web root and add the following lines in it.
    
    RewriteEngine on
    RewriteCond $1 !^(index.php|resources|robots.txt) 
    RewriteCond %{REQUEST_FILENAME} !-f 
    RewriteCond %{REQUEST_FILENAME} !-d 
    RewriteRule ^(.*)$ index.php/$1 [L,QSA]
    
    If the Codeigniter website is installed in some folder but not in root directly then you have to set the base folder to that. For doing it copy paste the following after the first line in step 3. Replace test with the actual folder name.
    
    RewriteBase /test/
    

Website in minutes

Do you know that you can generate a complete PHP websites in minutes with PHP Website Generator?

Features

  • Free admin dashboard
  • Role based security
  • Login with Facebook, Google and more
  • Queue based email processing
  • Price at $5 for website
  • Uses CodeIgniter framework

Generate website now See Pricing



You can generate an entire website in CodeIgniter using our PHP Website Generator using easy to use wizards. PHP Website Generator provide many features including search with pagination, AJAX based grid data editors, Group based security and free Admin dashboard etc. Please connect with Google or Facebook and to generate your CodeIgniter website in minutes.