"AFTER TODAY"

Remove ‘index.php’ in CodeIgniter (2.1.0)

Posted by: Moses Kurniawan on: December 6, 2011

It was a not-so-big issue. But I want it enabled in future production.

The default guide to remove .htaccess from CodeIgniter's manual is not work at all.

After googling, finally I found a solution from CodeIgniter's forum :

http://codeigniter.com/forums/viewthread/205290/P30

In short, you will need to modify a little of Apache default sites. Here is the guide :

1) Enable the mod_rewrite for Apache 2 first. Do sudo a2enmod rewrite and then sudo /etc/init.d/apache2 reload.

2) Edit the Apache default sites. Command : sudo nano /etc/apache2/sites-available/default. Make sure you don't copy paste directly to the default file! Where it is bold, it says None, change it from None to All.

<VirtualHost *:80>
      ServerAdmin webmaster@localhost

      DocumentRoot /var/www
      <Directory >
          Options FollowSymLinks
          AllowOverride All
      </Directory>
      <Directory /var/www>
          Options Indexes FollowSymLinks MultiViews
          AllowOverride All
          Order allow,deny
          allow from all
      </Directory>

3) Write this for your .htaccess file, make sure you put the .htaccess file in your web application folder. Not the CI's 'application' folder!

RewriteEngine On
RewriteBase /sebserver/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L] 

4) In config.php, remove the index.php text. Example :

$config['index_page'] = '';

Then enjoy!

Note : I use Ubuntu Server 11.04 with Apache version from Oneiric repo.

Advertisement

1 Response to "Remove ‘index.php’ in CodeIgniter (2.1.0)"

hi i using xamp ,test i can’t find

Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

, but i copy the .htacess file , but still cannot work , and display object not found error , my xamp problem

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.