How to remove index.php in codeigniter using htaccess

in the CodeIgniter project by default will br included index.php in the URL but it not user friendly and google search, so we need to remove index.php from url. In this tutorials we learn how we can remove index.php from url in codeigniter, so let's start..

STEP : 1 Create a .htaccess file in our Projet root directory.

htaccess image

STEP : 2  After .htaccess file created then if you can not see yout .htaccess file then you follw this step : Open cpanel => public_html => Click On setting and check mark on show hidden files of checkbox.

hidden file box

    STEP 3 : Open .htaccess file and paste below code :
  1. RewriteEngine On
  2. RewriteCond %{REQUEST_FILENAME} !-f
  3. RewriteCond %{REQUEST_FILENAME} !-d
  4. RewriteRule ^(.*)$ index.php/$1 [L]

STEP 4 :  Click and open file application -> config -> config.php and remove the index.php.

$config['index_page'] = "index.php";
To :
$config['index_page'] = "";

Post a Comment (0)
Previous Post Next Post