How Fo Fix .htaccess Problem In Codeigniter on Ubuntu 14.04 LAMP Stack Server?

All was working nicely in the localhost. But when I transfered the project on the Ubuntu 14.04 LAMP Stack Server, I was unable to access the .htaccess file in my projects root. Whenever I try to serve a page, I get a 404 error. After some research I found out the solution to fix it.

/* Preliminary steps to make sure the correct config in CI */

1. Make .htaccess file in your CI root directory using below code

   RewriteEngine on
   RewriteCond $1 !^(index\.php|assets|robots\.txt)
   RewriteRule ^(.*)$ index.php?/$1 [L]

2. Check /application/config/config.php and set $config['index_page'] = "";

3. make sure that mod_rewrite is on your server. Use phpinfo(), if you are not sure.


After enabling mod_rewrite, we need to change setting of AllowOverride to All
/* Change the apache2 configuration to enable override all */

1. Find your apache2.conf, in my case, it's in /etc/apache2/

2. So open it and change the expected feature:

   Find and change on <directory  /var/www/>
     AllowOverride none
     to
     AllowOverride All

3. Restart your apache to make sure new changes is activated. I did via terminal as below.

     root@example.se:~# service apache2 restart 

And it's working. :)

Comments

Post a Comment

Popular Posts