You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@httpd.apache.org by Denise Mangano <De...@complusdata.com> on 2003/06/02 17:06:57 UTC

[users@httpd] Redirect - condition only applying to one rule

I have a quick question regarding how the Rewrite directives get processed.
I have a rule that if the time is earlier than 2:00 am, rewrite the request
to a maintenance page.

Originally I wrote the rule as:
   RewriteCond   %{TIME_HOUR}%{TIME_MIN} <0200
   RewriteRule   ^\/index\.html$    /maintenance.html [L]
   RewriteRule   ^\/client1\/index\.html$   /client1/maintenance.html

What was happening here was that the time condition was being checked for.
If it matched, then index.html was rewritten.  If it didn't, it was passed
through.  However, the last RewriteRule was ALWAYS being applied regardless
of whether or not the condition was true. So I rewrote it to be:

   RewriteCond   %{TIME_HOUR}%{TIME_MIN} <0200
   RewriteRule   ^\/index\.html$    /maintenance.html [L]
   #Add RewriteCond And RewriteRule for each client directory
   RewriteCond   %{TIME_HOUR}%{TIME_MIN} <0200
   RewriteRule   ^\/client1\/index\.html$   /client1/maintenance.html

Now the condition is being checked for for each rule and this seems to work.
Did I do something wrong in the first set of code??  Or is it necessary to
write the RewriteCond every time?

Thanks.
Denise

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