Set document root for external subdomain (A Record) via htaccess
Posted
by
1nsane
on Server Fault
See other posts from Server Fault
or by 1nsane
Published on 2010-08-10T20:29:28Z
Indexed on
2012/03/24
23:31 UTC
Read the original article
Hit count: 163
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
© Server Fault or respective owner