Log
How To Install CakePHP in a Subdirectory Via an Apache Alias
The documentation on how to install CakePHP in a non-root directory (http://site.tld/directory_name/) is rather sparse, so here’s how to do it using an Apache Alias directive:
httpd.conf
In httpd.conf, add the following line:
Alias /directory_name /absolute/path/to/install/directory/app/webroot
.htaccess
In app/webroot/.htaccess, add the following line:
RewriteBase /directory_name
Your .htaccess file should now appear as such:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /directory_name
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]
</IfModule>
index.php
Finally, in app/webroot/index.php, at line 63, right below where it says not to edit below this line, change it to:
define('WEBROOT_DIR', 'directory_name');
Make it Work
Restart Apache and you should be all set.
07/27/06 08:09AM CakePHP
Comments
Hey there.
I use this method for developing lots of Cake apps..it’s a bit kludgy but has some merits (if you have a single dev set-up)
In httpd.conf for my Apache install (I use XAMPP on Mac os x 10.4)
Go to the DocumentRoot bit
# symbolic links and aliases may be used to point to other locations.
#DocumentRoot “/Applications/xampp/htdocs”
DocumentRoot “/path/to/cake/app/webroot”
and then add and comment out each line for each app, so I have lots of directories in my htdocs, each with a cake project in. It is annoying in that I have lots of cake library installs but does allow me to easily switch from one to another with a 2 character edit (comment/uncommet) in httpd.conf and then restart server :)
I think I will switch to your way when I re-do my system though. It is better to have a possiblity to link up an app with diff cake versions , since the codebase changes rather quickly.
08/13/07 6:01AM
I thank you very much!! This post saved me tons of time and energy.
I configured the above using the following:
1) Eclipse 3.3 Europa PDT
2) xampp 1.6.5
3) CakePHP 1.2
It can be done. FIST!
04/24/08 10:03PM
Add a Comment
Have something to say about what I wrote here? Let’s hear it!
- Your name and email address are required, but your email will not be displayed on the site
- If you provide a URL, a link to your site will appear
- You may use the following HTML:
<strong>bold</strong><em>italic</em><a href="http://url">links</a>
- Double line breaks will be converted to paragraphs.
- As you type, you should get a nice little preview of your comment directly below the text box.
- I reserve the right to edit any comment for any reason (I’ll be reasonable).
Recently Played on iTunes
-
“Here With Me”
'Merican
Descendents
06/30/09 17:01 -
“'Merican”
'Merican
Descendents
06/30/09 16:59 -
“Nothing With You”
'Merican
Descendents
06/30/09 16:57
Rimu:
It wasn’t working for me until I used define(‘BASE_URL’, ‘directory_name’); instead of define(‘WEBROOT_DIR’, ‘directory_name’);
06/10/07 9:09PM