How to remove index.php from URLs in CodeIgniter

codeigniter

For Localhost / VPS / Dedicated Hosting

  1. Open the httpd.conf
  2. Find
    LoadModule rewrite_module modules/mod_rewrite.so
  3. Remove # from the beginning of the line
  4. Find AllowOverride then change to be
    <Directory />
    AllowOverride All
    Order deny,allow
    Deny from all
    </Directory>
  5. Save and restart Apache
  6. Create a .htaccess file at the root directory
    #Rewrite index.php
    #Start using rewrite engine
    RewriteEngine On
    #Rewrite condition
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #Whenever index.php is there in the url, it will rewrite to / automatically
    RewriteRule .* index.php/$0 [PT,L]
  7. Make following changes in application/config.php
    $config['index_page'] = '';
  8. Save the file and you are done

For shared hosting

  1. Create a .htaccess file at the root directory
    #Rewrite index.php
    #Start using rewrite engine
    RewriteEngine On
    #Rewrite condition
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    #Whenever index.php is there in the url, it will rewrite to / automatically
    RewriteRule .* index.php/$0 [PT,L]
  2. Make following changes in application/config.php
    $config['index_page'] = '';
  3. Save the file and you are done

Have something to Add?

Loading Facebook Comments ...
Loading Disqus Comments ...