Welcome! Log In Create A New Profile

Advanced

Re: how to fix the rewrite rule?

Francis Daly
July 19, 2012 04:50AM
On Thu, Jul 19, 2012 at 04:32:47AM -0400, 21andy wrote:

Hi there,

> this works fine
> rewrite "^/([a-f0-9]{2})([a-f0-9]{18})\.(jpg|png|gif)$"
> /test.php?a=$1&b=$2&c=$3 last;
>
> open /a669164f02f6fdc18f.jpg
>
> test.php would output
> Array ( [a] => ad [b] => a669164f02f6fdc18f [c] => jpg )

Really?

Your url has 18 hex characters. Your rewrite rule will only match if
there are 20. And "[a] => ad" doesn't appear anywhere in your url.

> but this DO NOT WORK
> rewrite "^/([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{14})\.(jpg|png|gif)$"
> /test.php?a=$1&b=$2&c=$3 last;
> it return 404 error

Here your rewrite rule will only match if there are 18 hex characters.

I expect

[a] => a6 [b] => 69 [c] => 164f02f6fdc18f

> how can i fix this?

Be consistent.

How long is the url you want to test? Make sure you match exactly that
many characters in your rewrite rule.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

how to fix the rewrite rule?

21andy July 19, 2012 04:32AM

Re: how to fix the rewrite rule?

Francis Daly July 19, 2012 04:50AM

Re: how to fix the rewrite rule?

Elena Zwetkow July 19, 2012 05:14AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 311
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready