CakePHP: Setting up mod_rewrite on Ubuntu
Sunday, December 13th, 2009After installing CakePHP on my Ubuntu box, I viewed the default home page in my browser and noticed that the page was not styled. Cake did not know the path to the CSS file because I had not enabled mod_rewrite. Although I could opt to setup CakePHP to work without mod_rewrite, I decided to enable it.
First I had to make sure that mod_rewrite is enabled on Apache.
sudo a2enmod rewrite |
I then had to tell Apache where Cake’s webroot directory is located. I do this in the file ‘/etc/apache2/sites-available/default’, so I opened the file.
sudo pico /etc/apache2/sites-available/default |
Note: I use the Pico editor on my Mac, so I tend to use it on Ubuntu as well. You can use whatever editor you are most comfortable using (Nano, gedit, vi, etc).
I added a new rule after the first directory rule:
<Directory /var/www/app/webroot>
AllowOverride All
</Directory> |
Save this file and then restart Apache:
sudo /etc/init.d/apache2 force-reload |
That’s it. Now when I viewed CakePHP in my browser, the default styling displays correctly.



April 26th, 2010 at 8:19 am
Thanks for your post, fixed it for me(using code igniter).
The “AllowOverride All” for my app folder did the trick.