16 Oct
When developing with CakePHP, we can setup Apache to automatically redirect a domain to a specific CakePHP application.
We can set computer’s aliases using hosts file. Apache will automatically map aliases to different DocumentRoot:
app1.mybox.com -> /var/www/cakephp/app1.mybox.com/webroot
app2.somewhere.com -> /var/www/cakephp/app2.somewhere.com/webroot
Step 1: Enable the mod_vhost_alias:
Step 2: Replace the DocumentRoot statement in default virtualhost configuration file with two lines:
(If you use a different virtualhost, make sure that you’re editing the right configuration file)
Step 3: However, the mod_rewrite doesn’t play nice with mod_vhost_alias. We need to edit the .htaccess file in {APP}/webroot folder.
Step 4: Restart Apache.
Below is my default virtual host configuration for your reference:
Leave a reply