6th December 2011

Post

Remove ‘index.php’ in CodeIgniter (2.1.0)

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.

Posted via email from “AFTER TODAY” | Comment »