Breaking News
Loading...
,

Remove index.php from CodeIgniter

Share on Google Plus

Remove index.php from CodeIgniter




Steps to remove index.php from Codeigniter URL

In this article, we are going to discuss about How to enable SEF url in CodeIgniter (CI). We can get the SEF url by removing the index.php from the URL. If you are using Codeigniter you are noticed that by default index.php will be included with your URL. In this article I am going to explain about How to remove the index.php from the CodeIgniter (CI) site URL.

By removing the index.php from the URL we can get the site URL like below


To acheive this, follow the below steps.

Step 1 :

Open the folder "system/application/config" and open the file "config.php". find and replace the below code in config.php file.

find the below code

$config['index_page'] = "index.php" 

replace with the below code

$config['index_page'] = ""


Step 2 :

Create ".htaccess" file in the root of CodeIgniter (CI) directory. Then the below codes in the ".htaccess" file.

RewriteEngine on
RewriteCond $1 !^(index.php|resources|robots.txt)
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L,QSA]

In some case the default setting for uri_protocol does not work properly. To solve this problem just open the file "system/application/config/config.php", then find and replace the below code

find the below code

$config['uri_protocol'] = "AUTO" 

replace with the below code

$config['uri_protocol'] = "REQUEST_URI" 

You Might Also Like

0 comments

About me


Like us on Facebook