Report this

What is the reason for this report?

Ubuntu 14.04 apache mod_rewrite won't work with codeigniter htaccess

Posted on April 7, 2015

Hi, It looks like I have a huge problem. After all trying to fix it, nothing has changed. I have a problem with mod_rewrite engine - it is not working on my project.

I’ve created new fresh ubuntu 14.04 droplet with LAMP. Then, I’ve logged in with my CMD and entered following lines…:

sudo a2enmod rewrite
sudo nano /etc/apache2/sites-available/default

and than I rewrited default file with this info:

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

and after all I’ve restarted my apache. Then I have uploaded my project to /var/www/html/project/ directory. My project is using codeigniter framework and this is the .htaccess of my project:

RewriteEngine On
RewriteBase /html/project/

RewriteCond %{THE_REQUEST} \s/+(.*?)/{2,}([^\s]*)
RewriteRule ^ %1/%2 [R=302,L,NE]

RewriteCond %{THE_REQUEST} ^[A-Z]{3,}\s/+(.+?)/{2,}[?\s] [NC]
RewriteRule ^ /%1/ [L,R=301]

RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^ http://www.%{HTTP_HOST}%{REQUEST_URI}  [R=301,L]

RewriteCond %{REQUEST_URI} system|application
RewriteRule ^(.*)$ index.php?/$1 [L]

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

but the problem is, that mod_rewrite is not working… I can access pages via http://…/project/index.php/article instead of http://…/project/article

any ideas about it?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

So the problem was in nano /etc/apache2/apache2.conf file. I have to turn on my mod_rewrite there…

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.