httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joshua Slive <>
Subject Re: [users@httpd] mod_rewrite mass virtual hosting and aliases
Date Tue, 06 Dec 2005 15:08:43 GMT
On 12/6/05, gregory duchesnes <> wrote:
> oups, i don't understand you logic either ;)
> ok i'll try to make things clearer
> What i'm trying to do is this :
> - check if the folder /var/www/hosts/${lowercase:%{SERVER_NAME}}/web exists
> - if yes rewrite the request to this folder
> - else if SERVER_NAME is found in the (as first entry) then
> redirect request to the master domain ( second entry)

That's what I was guessing.  My example turned this logic around,
which I think is a better idea:
   redirect to map target
   serve from /var/www/hosts/SERVER_NAME

In either case, the results are undefined for hosts which are neither
in nor under /var/www/hosts.  But my logic is faster and

> I did some corrections and it should look like something like this, it's
> far from working but at least the fisrst part seems to work
> # if folder exists as a master domain
> RewriteCond /var/www/hosts/${lowercase:%{SERVER_NAME}}/web ^(.+)$

This doesn't do what the comment says.  I think you are looking for
the -f option to RewriteCond.  But it is best to avoid these kind of
tests, which is what I did in my example.

> # do the magic
> RewriteRule ^/(.*)$ /var/www/hosts/${lowercase:%{SERVER_NAME}}/web/$1 [L]
> # else redirect to the master domain
> RewriteCond ${vhost:%1} ^(/.*)$

This line is unnecessary.  The lookup can be put directly in the RewriteRule.

> RewriteRule ^(.*)   http://%2/$1  [QSA,L,R=301]

The QSA is unnecessary since you aren't changing the query string. 
The original one will get sent automatically.


The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:> for more info.
To unsubscribe, e-mail:
   "   from the digest:
For additional commands, e-mail:

View raw message