CakePHP mod_rewrite problems

I recently went to launch a website I had put together using CakePHP. Everything look good on my local computer. When I uploaded my content to their server, I saw a rather plain page.

It turns out that I was having a common issue with the mod_rewrite and the pre-built .htaccess files provided by the Cake libraries.

After a bit of research, I was able to correct my issues by adding the RewriteBase to the files. This is the .htaccess in the root directory of the site, as you can see I have added the “RewriteBase /” to the file.

<IfModule mod_rewrite.c>
   RewriteEngine on
   RewriteBase /
   RewriteRule    ^$   app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]

I also had to make this change to the /app/webroot/.htaccess file, but this time the Rewrite base looked like “RewriteBase /app/webroot”

I now have a much firmer understanding of how Apache mod_rewrite works.