So the rewrite rule should take the number and split it, taking the 1st
(420) and 2nd (006) three numbers out of the url and rewrite it to the
local path. But the number isn’t always that long, it may also be only 1
to 5 places long, e.g. 1, 12345 and 456 are possible. If the number is
less than 6 places long, the rewrite should fill up the missing places
with the character x.
Optional there’s a hyphen in front of the long number, e.g.
/img/default/-420006675369688559/image.png
Brilliant concept, but i wasn’t asked… So far, so bad. So i wrote some
rules, but as you might suggest, they don’t work. Here they are…
Maybe i don’t even need the locations… I’ve tried the last rule alone,
with a rewrite to a website, but even that doesn’t work, so there must
be some severe (logical) error in the location/rewrite rule.
On Tue, Aug 24, 2010 at 03:15:46AM -0400, revirii wrote:
(420) and 2nd (006) three numbers out of the url and rewrite it to the
}
# 5 numbers
Maybe i don’t even need the locations… I’ve tried the last rule alone,
with a rewrite to a website, but even that doesn’t work, so there must
be some severe (logical) error in the location/rewrite rule.
Any help would be weclome
You DO need the locations, but you DO NOT need the rewrites.
Why do you use space in “([0-9] {2}” ?
Here is example for 2 numbers location:
# 2 numbers
location ~ ^/img/default/-?(\d{2})/.+\.(.+)$ {
alias /home/images/public/$1x/xxx/$1/default.$2;
}
{
alias
/home/images/public/$1x/xxx/$1/default.$2;
}
Hm, what is \d{2}? Is there any documentation? And:
nginx -t
2010/08/24 14:40:25 [emerg] 7386#0: pcre_compile() failed: missing ) in
"^/img/default/-?(\d"
2010/08/24 14:40:25 [emerg] 7386#0: the configuration file
/etc/nginx/nginx.conf test failed
I put it into “…”:
location ~ "^/img/default/-?(\d{2})/.+\.(.+)$"
But then i see:
2010/08/24 14:48:34 [emerg] 7449#0: the "alias" directive may not be
used inside location given by regular expression
2010/08/24 14:48:34 [emerg] 7449#0: the configuration file
/etc/nginx/nginx.conf test failed