On 12/6/05, gregory duchesnes <[EMAIL PROTECTED]> 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 vhost.map (as first entry) then
> redirect request to the master domain (vhost.map second entry)

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

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

> 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.

Joshua.

---------------------------------------------------------------------
The official User-To-User support forum of the Apache HTTP Server Project.
See <URL:http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: [EMAIL PROTECTED]
   "   from the digest: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to