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 127.0.0.0/255.0.0.0 ::1/128 10.254.239.0/255.255.255.0

# 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

0 Comments

Submit a Comment

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

The reCAPTCHA verification period has expired. Please reload the page.

You May Also Like…

Clear HSTS Settings in CHrome

Open chrome://net-internals/#hsts enter the domain in the query field and click Query to confirm it has HSTS settings...

Ubuntu on Hyper-v

It boils town to installing linux-azure # as root or sudo apt-get update apt-get install linux-azure...