How to remove index.php in CodeIgniter
×

How to remove index.php in CodeIgniter

1908


Related Topics

Codeigniter Interview questions
Login form in Codeigniter
Create Registration form in Codeigniter

For example:

http://localhost/ci/index.php/Upload_controller

If I render this URL into the browser, I found the result

If I remove index.php from the above URL, it will give a page not found error.

In above URL index.php is unnecessary and we can remove this with the help of the .htaccess file.

Removing index.php file

Here are few simple steps by following them we can easily remove index.php from our application URLs and make them friendly for users and search engines.

Step 1 First of all, open the application/config/config.php file and search index_page in it.

Make this parameter value blank.

So, replace the above line from this line:

$config['index_page'] = '';

Step 2 Create a .htaccess file at the root directory of your application and save the given code in that file.

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

Step 3 Now, remove index.php from your application URL and render it in the browser to see the result.

Now it works perfectly without generating any error.



Best WordPress Hosting


Share:


Discount Coupons

Get a .COM for just $6.98

Secure Domain for a Mini Price



Leave a Reply


Comments
    Waiting for your comments