Remove index.php in Codeigniter

Remove index.php in Codeigniter- Apache nginx localhost
  • 2
    Shares

In this tutorial I will explain you how to remove index.php from Codeigniter in Apache or Nginx (wamp, xampp or Ubuntu).

As we know Codeigniter by default add index.php in URL which makes URL like this:

example.com/index.php/users/aftabmuni

But this looks not good as per user as well as SEO point of view, so to make it more readable and clean we try to remove this index.php from URL.

example.com/users/aftabmuni

To achieve this we have to follow below steps:

Step 1: Remove index.php from config.php

Open /application/config/config.php and remove index.php to “”

Step 2: Edit htaccess file – For Apache Server

NOTE: This step is not for nginx server users, Please check Step 2 for Nginx.

If you are using Apache server (Wamp, Xampp, Mamp etc) then you will have to edit .htaccess file which you will find in root directory.

Open this .htaccess file and add below code in it:

If your Codeigniter is present in sub folder then use below code:

Step 2: Edit nginx.conf file – For NGINX Server

NOTE: This step is not for Apache server users, Please check Step 2 for Apache.

Find your nginx.conf file and search for server block:

And in server block add below code in location /

So your server block will look like:

If your Codeigniter is in sub folder then use below code:

That’s it, once you will change above thing correctly then you can see index.php is removed from the URL.

Leave a Reply

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