httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Krist van Besien" <>
Subject Re: [users@httpd] defining subdomains rewrite-rule outside of vhosts
Date Sun, 18 Nov 2007 11:25:53 GMT
On Nov 16, 2007 6:40 PM, Samuel Vogel <> wrote:
> Hey guys,
> I am looking for a way to put my rewrite rule for subdomains outside of
> each virtual host into the global config to safe space and simplify my
> configuration.
> Here is what I tried. We own the domains, and
> And we give to our users. Our users are able
> to define subdomains like and those requests should
> go to the "sub"-folder.
> Here is what I tried:
> <IfModule mod_rewrite.c>
>         RewriteEngine On
>         RewriteCond %{HTTP_HOST}
> !^(www.)?([a-z0-9-]+).(netgag|kilu[23]?).de$ [NC]
>         RewriteCond %{HTTP_HOST}
> ^(www.)?([a-z0-9-]+).([a-z0-9-]+).(netgag|kilu[23]?).de [NC]
>         RewriteRule (.*) %2/$1 [L]
> </IfModule>
> Unfortunately this doesn't work. The rewrite rule does not redirect a
> request to
> Does anybody see the mistake?

RewriteRules are not inherited by virtual hosts, unless you add the
following to the virtual host block:

RewriteOptions Inherit

But this might nog be enough. You must realize that requests to will nog get handed over to the virtual host This is not how it works. They will in stead be
handed over to the default (first) virutal host as the hostname will
not match any virtual host.
What you could do is have all your rules in the default virtual host.
Also set a rewrite log and a sufficiently high rewritelog level, so
you can see if the rules get processed, and how.

You might also want to look in to mod_vhost_alias.


Bremgarten b. Bern, Switzerland
A: It reverses the normal flow of conversation.
Q: What's wrong with top-posting?
A: Top-posting.
Q: What's the biggest scourge on plain text email discussions?

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