I have working CakePHP app on web server, and now I want to have WIP joomla on subdomain. And because of my webhosting way to deal with subdomains I'm unable to write proper conditions in htaccess to have it working. By default my CakePHP app is in /www fodler on the server and its htacces look as follows
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]
</IfModule>
My webhosting provider way to deal with subdomains is to create folder inside subfolder of /www that is named as required subdomain and redirect to it.
So if I want to create subdomain joomla.mydomain.com I have to create folder /www/subdom/joomla and than add proper conditions and rules to htaccess
# subdomains(with or without www in the begenning)
RewriteCond %{REQUEST_URI} !^subdom/
RewriteCond %{REQUEST_URI} !^/subdom/
RewriteCond %{HTTP_HOST} ^(www\.)?(.*)\.([^\.]*)\.([^\.]*)$
RewriteCond %{DOCUMENT_ROOT}/subdom/%2 -d
RewriteRule (.*) subdom/%2/$1 [DPI]
But when this is added to to htaccess cakePHP works as before, but acessing joomla subdomain throws Internal Server Error. However if I comment out last rewrite rules
#RewriteRule ^$ app/webroot/ [L]
#RewriteRule (.*) app/webroot/$1 [L]
subdomain starts working properly.
I wrote a blog post on using other apps within CakePHP here