Set document root for external subdomain (A Record) via htaccess
- by 1nsane
I have a managed server (unable to control apache settings) with the default document root of: /var/www
I have a web app running in: /var/www/subdomains/app/webroot
I have a dedicated domain managed by the host that has the aforementioned webroot which works perfectly. I would like to allow externally provisioned domains to point to the server/web app via A Record config. If I access the site via IP, it takes me to the index located in /var/www.
I would like to configure the .htaccess in my /var/www directory to rewrite requests from the external subdomain to the /var/www/subdomains/app/webroot directory. I've done so using the following rules:
RewriteCond %{HTTP_HOST} external\.domain\.com$ [NC]
RewriteRule ^(.*)$ /var/www/subdomains/app/webroot/index.php?url=$1 [L,QSA]
When accessing external.domain.com, the app loads properly, but the paths to things like CSS files, images, etc. are prefixed with "/subdomains/app/", causing broken links.
I've tried changing the RewriteBase (both in /var/www and /var/www/subdomains/app/webroot), as I believe that's what it's designed for - but no luck.
Any ideas?
FYI the app is built on CakePHP.
Thanks