Multiple conditions for rewrite
Corey Donohoe
atmos at atmos.org
Thu May 8 03:26:42 MSD 2008
On Wed, May 7, 2008 at 10:42 AM, Andrei GUDIU <andreig at openbsd-box.org> wrote:
> heya heya
> does anybody know how I could user ngx rewrite to port the mod_rewrite ability
> to have multiple conditions ?
> like:
> RewriteCond cond1
> RewriteCond cond2
> RewriteRule xmoo bla
>
> the current config I am using:
> if (cond1 && cond2) {
> }
>
> does not work (also using &, and does not work)
>
> and:
> if (cond1) {
> if (cond2) {
> }
> }
>
> does not work either :(
>
> Should I use something like the "break"/"last" combinations ?
>
>
>
You can't nest if statements in nginx. Every time that I've needed
nested if statements I've been able to wrap it up in a separate
location block or something similar. Sometimes you have to think
about it for a little bit, but the solution usually presents itself.
You probably can leverage break/last to allow fall through in your
logic, but personally I always incorrectly guess the behavior the
first time I look at mroe complex rewrites. :)
I'd love to see nested ifs in nginx but I am a little scared about how
people will use them.
--
Corey Donohoe
http://www.atmos.org/
http://www.engineyard.com/
More information about the nginx
mailing list