You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Klavs Klavsen <kl...@vsen.dk> on 2003/06/25 10:10:57 UTC

[users@httpd] FIXED: [users@httpd] vhost_alias/VirtualDocumentRoot is useless?

Fixed it :)

# define the map file
RewriteMap vhost txt:/www/costumers/shared/conf/vhost.map

RewriteCond ${lowercase:%{SERVER_NAME}} ^(.+)$ - vhost right column is
/vhost-dir - without documentroot
# this does the file-based remap
RewriteCond ${vhost:%1} ^(.*)$

# rewrite to correct url and C=use this url instead.
RewriteRule ^/(.*)$     $1/html/$1 [C]

 - before my rewriterules makes it work :)

Now I also figured out how to do it without rewritemap - which I tried
before but didn't work - now it does - some subtle difference must be
the reason:

# match www.*.*
RewriteCond   %{HTTP_HOST}              ^www\.[^.]+\.[^-]+$ [NC]
RewriteRule   ^(.+)                     ${lowercase:%{HTTP_HOST}} [C]
RewriteRule   ^www\.([^.]+)\.([^.]+)    -       [E=domain:$1]

# match *.*
RewriteCond   %{HTTP_HOST}              ^[^.]+\.[^-]+$ [NC]
RewriteRule   ^(.+)                     ${lowercase:%{HTTP_HOST}} [C]
RewriteRule   ^([^.]+)\.([^.]+)         -       [E=domain:$1]

# rewrite to correct url and C=use this url instead.
RewriteRule ^/(.*)$     $domain/html/$1 [C]

This way I don't need vhosts.map file - and thus it works for every
domain that there is a directory for.

Only thing is that the thing only works for www.domain.tld and for
domain.tld - suggestions as howto make this work for all subdomains
(and, but not necessarily, second level subdomains) are welcome :)

But I can live with it working as it does now.

-- 
Regards,
Klavs Klavsen, GSEC - kl@vsen.dk - http://www.vsen.dk
PGP: 7E063C62/2873 188C 968E 600D D8F8  B8DA 3D3A 0B79 7E06 3C62

Working with Unix is like wrestling a worthy opponent. 
Working with windows is like attacking a small whining child 
who is carrying a .38.				



---------------------------------------------------------------------
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: users-unsubscribe@httpd.apache.org
   "   from the digest: users-digest-unsubscribe@httpd.apache.org
For additional commands, e-mail: users-help@httpd.apache.org