How to remove index.php from codeigniter in UBUNTU [duplicate] How to remove index.php from codeigniter in UBUNTU [duplicate] codeigniter codeigniter

How to remove index.php from codeigniter in UBUNTU [duplicate]


Step 1 :

Add this in htaccess file

<IfModule mod_rewrite.c>  RewriteEngine On  #RewriteBase /  RewriteCond %{REQUEST_FILENAME} !-f  RewriteRule ^ index.php [QSA,L]</IfModule>

Step 2 :

Remove index.php in codeigniter config

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

Step 3 :

Allow overriding htaccess in Apache Configuration (Command)

sudo nano /etc/apache2/apache2.conf

and edit the file & change to

AllowOverride All

for www folder

Step 4 :

Enabled apache mod rewrite (Command)

sudo a2enmod rewrite

Step 5 :

Restart Apache (Command)

sudo /etc/init.d/apache2 restart


In application/config/config.php change:

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

to:

$config['index_page'] = '';

it is a good idea to do apache reload everytime you change an apache config file.

sudo /etc/init.d/apache2 reload

or:

sudo service apache2 reload

or:

sudo /etc/init.d/httpd reload

(or whatever is the equivalent command for your platform)

for what it is worth, here is my .htaccess

RewriteEngine onRewriteBase /RewriteCond $1 !^(index\.php|static|robots\.txt|favicon\.ico|uploads|googlexxxxxxxx\.html|mobile.html)RewriteRule ^(.*)$ index.php/$1 [L]


my .htaccess

RewriteEngine onRewriteCond $1 !^(index.php)RewriteRule ^(.*)$ index.php/$1 [L]