httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philip Wigg <>
Subject Re: [users@httpd] Avoid endless loop of mod_rewrite
Date Mon, 08 Mar 2010 09:12:16 GMT
On 8 March 2010 05:17, Michael Menegakis <> wrote:
> Hi all
> A rule is in place that that rewrites domains to
> In one particular home dir, I need the opposite,
> RewriteEngine On
> RewriteCond %{HTTP_HOST} ^$ [NC]
> RewriteRule ^(.*)$$1 [R=301,L]
> But it goes into an endless loop that eventually makes firefox spit
> 'The page isn't redirecting properly
> Firefox has detected that the server is redirecting the request for
> this address in a way that will never complete.'
> How to ignore the higher level rule?

Can you not add an extra RewriteCond to each rule to check if you are
or aren't in the 'one particular home dir' or not? For example:-

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{REQUEST_URI} ^/homedir/.*                     <-- This
rule only applies if we're in /homedir/
RewriteRule ^(.*)$$1 [R=301,L]

RewriteCond %{HTTP_HOST} ^$ [NC]
RewriteCond %{REQUEST_URI} !^/homedir/.*                     <-- This
rule only applies if we're not in /homedir/, note the exclamation
RewriteRule ^(.*)$$1 [R=301,L]

-- Phil

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