RSS

How to remove index.php from CodeIgniter URL in Ubuntu

03 May
Codeigniter

CodeIgniter

 

In application/config/config.php change:

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

to:

$config['index_page']='';

 

Create or modify .htaccess in project root with following content.

# Customized error messages.
ErrorDocument 404 /index.php
# Set the default handler.
DirectoryIndex index.php
# Various rewrite rules.
<IfModule mod_rewrite.c>
  RewriteEngine on
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule ^(.*)$ index.php?/$1 [L,QSA]
</IfModule>

Also allow overriding htaccess in your apache

/etc/apache2/sites-available/default

and edit the file & change to

AllowOverrideAll

and

Restart Apache

 

sudo /etc/init.d/apache2 reload

or:

sudo service apache2 reload

or:

sudo /etc/init.d/httpd reload
Advertisements
 
1 Comment

Posted by on May 3, 2014 in Codeigniter

 

Tags:

One response to “How to remove index.php from CodeIgniter URL in Ubuntu

  1. fatkhur

    February 9, 2015 at 10:18 pm

    nice.. thank a lot, my problem solved.

     

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: