rewrite based on several and'ed conditions...
Aleksandar Lazic
al-nginx at none.at
Wed Jun 20 10:15:42 MSD 2007
Hi,
On Die 19.06.2007 09:32, Brice Figureau wrote:
>
>In Apache, I can decide to rewrite based on multiple conditions like:
>(totally stupid example ahead):
>RewriteCond %{REQUEST_METHOD} ^(GET|HEAD)$
>RewriteCond %{USER_AGENT} GoogleBot
>RewriteRule ^ /index.html [L]
>
>It doesn't seem to be possible under nginx except using this lame trick:
>
>if ( $request_method ~ (GET|HEAD) ) {
> rewrite ^(.*)$ /get-or-head$1;
> break;
>}
>
>location ^~ /get-or-head/ {
> if ( $user_agent ~ GoogleBot ) {
> rewrite ^ /index.html last;
> }
> # back to normal
> rewrite ^/get-or-head(.*)$ $1 last;
> break;
>}
>
>Is there a better alternative ?
Maybe with mod_perl: http://wiki.codemongers.com/NginxEmbeddedPerlModule
>If not, could it be possible to have the operator && and || defined in
>if() or at least leave the possibility to use interleaved if():
[snipp]
Yep this would be nice, I don't know if this is yet possible ;-)
Cheers
Aleks
More information about the nginx
mailing list