Getting CakePHP working in your Home Directory

Written by James McDonald

March 15, 2011

This presumes you know about the security implications of having pages served from you home dir and have taken appropriate precautions to stop unauthorized access:

# add a new directory section to apache

sudo vi /etc/apache2/sites-enabled/000-default
Alias /mapp/ "/home/userme/maps/mapp/"

        Options Indexes MultiViews FollowSymLinks
        AllowOverride All # important to allow .htaccess
        Order deny,allow
        Deny from all
        Allow from ::1/128

# enable mod rewrite in apache

 sudo a2enmod rewrite  && sudo service apache2 restart

# edit the CakePHP access files so they do sensible rewriting.

.htaccess located in Cake Root which in my setup it is /home/userme/maps/mapp/ (this is the directory inside which the CakePHP app, plugins & cake directories are)

   RewriteEngine on
   RewriteBase /mapp/ # add this
   RewriteRule    ^$ app/webroot/    [L]
   RewriteRule    (.*) app/webroot/$1 [L]

.htaccess located in CakeRoot/app/

    RewriteEngine on
    RewriteBase  /mapp/ # add this
    RewriteRule    ^$    webroot/    [L]
    RewriteRule    (.*) webroot/$1    [L]

.htaccess located in CakeRoot/app/webroot/

    RewriteEngine On
    RewriteBase /mapp/ #add this
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

# remember to restart apache
sudo service apache2 restart

BTW: The above is available in the _very_ good CakePHP Documentation


Submit a Comment

Your email address will not be published. Required fields are marked *

You May Also Like…

Toggen builds a new website

So I have built and hosted a new website for Roger Clark Pest Management they are a family owned and operated Pest...


Just downloaded WizTree (not a sponsor) from It seems to do what it says on the tin which is...

Scam call from “Telstra”

Just had a call from a man with a sub-continental accent from caller ID 0734946596 Told me there was problem with my...