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 07:54:10 UTC

[users@httpd] vhost_alias/VirtualDocumentRoot is useless?

Hi.

Can it really be that mod_vhost_alias is useless, as soon as you want to use RewriteRules too?
I can ofcourse just use virtualhosts for each - but that's manual work for each
vhost my users want to make - it would be much nicer (and efficient) if they could just
upload files in the correct dir - and have their vhost running automagically.

If anybody is using vhost_alias(ie. the VirtualDocumentRoot directive) and rewriterules I would VERY much like to see their rewriterules.

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


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

Posted by Klavs Klavsen <kl...@vsen.dk>.
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


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

Posted by Klavs Klavsen <kl...@vsen.dk>.
On ons, 2003-06-25 at 08:10, Zac Stevens wrote:
> On Wed, Jun 25, 2003 at 07:54:10AM +0200, Klavs Klavsen wrote:
[SNIP]
> Alternatively, you may be able to do away with VirtualDocumentRoot and let
> mod_rewrite take care of everything.  See the Mass Virtual Hosting
> documentation for more details:
> 
> http://httpd.apache.org/docs-2.0/vhosts/mass.html

Thank you. I hadn't seen the updated version of that.

I actually got this to work:
# define the map file
RewriteMap vhost txt:/www/costumers/shared/conf/vhost.map

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

and I can then use %1 in my next rewriterule.

Only - how do I make the %1 work in every rewriterule? (it only works in
the first one).

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


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

Posted by Zac Stevens <zt...@cryptocracy.com>.
On Wed, Jun 25, 2003 at 07:54:10AM +0200, Klavs Klavsen wrote:
> Can it really be that mod_vhost_alias is useless, as soon as you want to use RewriteRules too?

Not at all.  It just means that you can't expect some variables to be set
as they would in a normal Virtual Host - most notably the DocumentRoot.
The obvious consequence of this is that you cannot make references to paths
relative to the docroot.

That shouldn't be a problem as you will probably be able to replicate your
VirtualDocumentRoot globbing in your RewriteRules.  It might seem untidy to
solve the same problem twice, but that comes with using mod_vhost_alias.

Alternatively, you may be able to do away with VirtualDocumentRoot and let
mod_rewrite take care of everything.  See the Mass Virtual Hosting
documentation for more details:

http://httpd.apache.org/docs-2.0/vhosts/mass.html


Cheers,


Zac

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