Remove index.php from the address bar from CodeIgniter

 

It is possible to remove index.php from the web browser address bar when CodeIgniter is running. This can be done by following these steps:

  1. Create or open a .htaccess file. If a .htaccess file does not already exist, you can create one using the following:
    • Linux/Mac: Open a terminal window and type the following:
      touch /path/to/CodeIgniter/.htaccess
      
    • Windows: Create a text file in your CodeIgniter root, naming it file.htaccess. Hold down the Windows key and then press R to open the Run dialogue. Enter the following command and click on OK:
      ren "C:pathtoCodeIgniterfile.htaccess" .htaccess
      
  2. Once your .htaccess file is opened, write the following lines at the top of the file:
    <IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteCond $1 !^(index.php|images|robots.txt)
    RewriteRule ^(.*)$ index.php/$1 [L]
    </IfModule>
Recommended :  Create A URL Shortener website with codeigniter

About the author

Deven Rathore

I'm Deven Rathore, a multidisciplinary & self-taught designer with 3 years of experience. I'm passionate about technology, music, coffee, traveling and everything visually stimulating. Constantly learning and experiencing new things.

Pin It on Pinterest

Shares