httpd-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Boyle Owen" <Owen.Bo...@swx.com>
Subject RE: [users@httpd] Rewrite If Statements
Date Wed, 23 Feb 2005 16:56:33 GMT
> -----Original Message-----
> From: Nick Gushlow [mailto:nick.gushlow@westcoast.co.uk]
> Sent: Mittwoch, 23. Februar 2005 17:34
> To: users@httpd.apache.org
> Subject: RE: [users@httpd] Rewrite If Statements
> 
>

Following from Joshua's comment, I should point out that I'd forgotten
about the [L] (last) flag. This allows you to make full-scale switch
statements, eg:

	RewriteCond condition_1
	RewriteRule rule_1 [L]

	RewriteCond condition_2
	RewriteRule rule_2 [S=1]
	RewriteRule rule_3

Now cond_1 and cond_2 don't need to be mutually exclusive. If cond_1 is
true, rule_1 gets executed then we exit mod_rewrite.

Rgds,
Owen Boyle
Disclaimer: Any disclaimer attached to this message may be ignored.  

> On Wed, 2005-02-23 at 16:20 +0100, Boyle Owen wrote:
> 
> > You can achieve this using the "S" flag to the RewriteRule. 
> This causes
> > mod_rewrite to "skip" the next N rules. For example:
> > 
> > if (condition_1)
> > 	rule_1
> > else
> > 	rule_2
> > 
> > is implemented by:
> > 
> > RewriteCond condition_1
> > RewriteRule rule_1 [S=1]
> > RewriteRule rule_2
> > 
> > This is the fundamental logic element (if-then-else). Note that this
> > just allows a two-way switch. It doesn't give you the full multiplex
> > switching (case-statement) that you might need. You might 
> get away with:
> > 
> > RewriteCond condition_1
> > RewriteRule rule_1
> > 
> > RewriteCond condition_2
> > RewriteRule rule_2 [S=1]
> > RewriteRule rule_3
> > 
> > so long as condition_1 and condition_2 are mutually 
> exclusive (ie, can't
> > both be true).
> 
> Ah ok, that looks like what I need; wasn't sure I could separate
> conditions and rules.
> 
> 
> Thanks,
> 
> Nick.
> 
> ---------------------------------------------------------------------
> 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
> 
>

This message is for the named person's use only. It may contain
confidential, proprietary or legally privileged information. No
confidentiality or privilege is waived or lost by any mistransmission.
If you receive this message in error, please notify the sender urgently
and then immediately delete the message and any copies of it from your
system. Please also immediately destroy any hardcopies of the message.
You must not, directly or indirectly, use, disclose, distribute, print,
or copy any part of this message if you are not the intended recipient.
The sender's company reserves the right to monitor all e-mail
communications through their networks. Any views expressed in this
message are those of the individual sender, except where the message
states otherwise and the sender is authorised to state them to be the
views of the sender's company. 



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


Mime
View raw message