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…

Squarespace Image Export

To gain continued access to your Squarespace website images after cancelling your subscription you have several...

MySQL 8.x GRANT ALL STATEMENT

-- CREATE CREATE USER 'tgnrestoreuser'@'localhost' IDENTIFIED BY 'AppleSauceLoveBird2024'; GRANT ALL PRIVILEGES ON...

Exetel Opt-Out of CGNAT

If your port forwards and inbound and/or outbound site-to-site VPN's have failed when switching to Exetel due to their...