httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrea Rossignoli" <>
Subject Re: [users@httpd] Stop ReWrite Infinite Loops?
Date Tue, 15 Apr 2003 06:11:28 GMT

>I am trying to setup some rewriting, but I can't get out of an infinite
>loop.  Here are my rules:
>RewriteCond   %{HTTP_HOST}                 ^[^.]+\.server\.com$
>RewriteCond %{REQUEST_URI} !^/var/www/hosts
>RewriteRule   ^(.+)                        %{HTTP_HOST}$1          [C]
>RewriteRule   ^([^.]+)\.server\.com(.*) /var/www/hosts/%{HTTP_HOST}/docs

If I'm right you want that every request to a subdomain is redirected to a
particular directory.
So put this code into an .htaccess or inside a directory block of your
document root into your httpd.conf

RewriteEngine On

# Extract the subdomain from the host name
RewriteCond %{HTTP_HOST} ^([^.]+)\.server\.com$ [NC]
# Verify that it's not www because it's the main server
RewriteCond %1 !^www$ [NC]
# Verify that an internal request was not in progress
RewriteCond %{REQUEST_URI} !^/var/www/hosts [NC]
# Okay, finally make the redirection
RewriteRule (.*) /var/www/hosts/%1/docs/$1 [L]

Remember that /var/www/hosts/etcetc is not an absolute directory path,
but it's relative to your document root.

Maybe it should be possible to do the same thing with some virtual host
but you asked for mod_rewrite and I showed an example.

Hope it helped,

Thank you,
:-) Andrea

----- Original Message -----
From: "Marc Boorshtein" <>
To: <>
Sent: Monday, April 14, 2003 23:16
Subject: [users@httpd] Stop ReWrite Infinite Loops?

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