We are working on giving our developers a 'sandbox' where they can create new sites under a base directory structure we have setup for them. The problem is the sites change from day to day, based on their site name and its a real issue for us to have to keep modifying the virthosts-sandbox.conf file for each site name change.
Is it possible to use the Rewrite Engine (or any other module) to just direct the site instead, based on what the DNS entry is seen as? Our DNS points each site to a universal CNAME (sandbox.domainname.com).
DNS db.domain.com entry:
- Code: Select all
sandbox1 IN CNAME sandbox.domain.com
Current virthosts-sandbox.conf file:
- Code: Select all
NameVirtualHost *:80
Listen 111.222.333.444:80
<VirtualHost *:80>
ServerName sandbox.domain.com
DocumentRoot /web/sandbox.domain.com
ErrorLog /var/web/sandbox.domain.com/error_log
CustomLog /var/web/sandbox.domain.com/access_log common
<Directory /web/sandbox.domain.com>
Options Indexes +FollowSymLinks Multiviews +Includes
AllowOverride All
</Directory>
</VirtualHost>
Under the /web/sandbox.domain.com directory, the .htaccess file:
- Code: Select all
Options +FollowSymLinks
RewriteEngine On
RewriteBase /web/sandbox.domain.com/
RewriteCond %{HTTP_HOST} ^(sandbox\.)?((domain)\.com)$ [NC]
RewriteRule ^(.*)$ http://sandbox.domain.com/$1/htdocs [R=301,L]
Server-Side Directory Structure
- Code: Select all
/web/sandbox.domain.com
drwxr-xr-x 7 www content 4096 Aug 7 15:58 sandbox1.domain.com
/web/sandbox.domain.com/sandbox1.domain.com
drwxr-xr-x 2 www content 4096 Aug 7 15:58 cgi-bin
drwxr-xr-x 2 www content 4096 Aug 7 16:28 htdocs
drwxr-xr-x 2 www content 4096 Aug 7 15:58 working
/web/sandbox.domain.com/sandbox1.domain.com/htdocs
-rw-r--r-- 1 www content 21 Aug 7 16:28 index.php
The idea is that when a developer tries to go sandbox1.domain.com, the instance will actually redirect them to http://sandbox.domain.com/sandbox1.domain.com instead.
We just don't want to have to keep modifying the virthosts-sandbox.conf for each new domain name being addressed. We are talking about several hundred sites found in the virthosts-sandbox.conf file, thus the reason for the request.
-- Michael