Here we are going to take about how to fix ” Fixing Mod Rewrite Issue” in CakePHP. I’m sure if you have(tried) installed CakePHP in Ubuntu, you definitely would have seen this message.
” URL rewriting is not properly configured on your server.”
And the darn page opens without any css and no URL rewriting (ofcourse, duh!)
Just follow the below checklist, I’m sure you might have missed any one of’em(like i did now ^^”)
Following are the Checklist for Fixing Mod Rewrite Issue
1. Verify all three .htaccess. (yep, three!)
~/projects/cakephp/.htaccess
1 2 3 |
RewriteEngine on RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] |
~/projects/cakephp/app/.htaccess
1 2 3 |
RewriteEngine on RewriteRule ^$ webroot/ [L] RewriteRule (.*) webroot/$1 [L] |
~/projects/cakephp/app/webroot/.htaccess
1 2 3 4 |
RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] |
(Important: If you have tried unzip the content of CakePHP source, somehow, .htaccess in ~/projects/cakephp/
got left out… damn!!!)
2. Enable mod rewrite ofcourse! (just double check it :P)
1 |
sudo a2enmod rewrite |
3. Proper permission for /tmp and /webroot
1 2 3 |
sudo chmod -R 777 webroot/ sudo chmod -R 777 tmp/ |
4. Enable “AllowOverride” in Apache
1 2 3 4 5 6 7 8 9 10 11 12 |
$ cd /etc/apache2/sites-available $ vi default Options FollowSymLinks AllowOverride All Options Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all |
5. Check for `cake.generic.css’ (Seriously, crazy fix!!!)
1 |
`~/projects/cakephp/app/webroot/css/cake.generic.css` |
CakePHP guys showing the URL rewriting issue if the css is not present. sheessh!!! (pss: I’m using CakePHP 1.3, my favorite!!!)
Well, Thats it for Fixing Mod Rewrite Issue!!!! I’m sure one em will help you fellas or else you will ended up spending hours scratching your head!! xD