How to remove index.php from codeigniter in UBUNTU?

This tutorial will show you that how to remove index.php from codeigniter in UBUNTU or how to enable url rewriting.

Step 1 :

Add this in htaccess file

<IfModule mod_rewrite.c>
  RewriteEngine On
  #RewriteBase /

  RewriteCond {3b3dd3986446f2411a115859dfb9ef0645ca07550196603d49955fcfabeac62d}{REQUEST_FILENAME} !-f
  RewriteRule ^ index.php [QSA,L]
</IfModule>
1<IfModule mod_rewrite.c> 2 RewriteEngine On 3 #RewriteBase / 4 5 RewriteCond {3b3dd3986446f2411a115859dfb9ef0645ca07550196603d49955fcfabeac62d}{REQUEST_FILENAME} !-f 6 RewriteRule ^ index.php [QSA,L] 7</IfModule>

Step 2 :

Remove index.php in codeigniter config

$config['index_page'] = '';
1$config['index_page'] = '';

Step 3 :

Allow overriding htaccess in Apache Configuration (Command)

 

sudo nano /etc/apache2/apache2.conf
1sudo nano /etc/apache2/apache2.conf

and edit the file & change to

AllowOverride All
1AllowOverride All

for www folder

Step 4 :

Enabled apache mod rewrite (Command)

sudo a2enmod rewrite
1sudo a2enmod rewrite

Step 5 :

Restart Apache (Command)

sudo /etc/init.d/apache2 restart
1sudo /etc/init.d/apache2 restart

Source