"[emerg]: pcre_compile() failed: missing terminating ]" in rewrite rule.

Grzegorz Sienko staff at krecio.pl
Thu May 13 15:17:15 MSD 2010


Hi

Thanks Maxim, everything work like a charm now :)

-- 
 Best Regards
Grzegorz Sieńko

2010/5/12 Maxim Dounin <mdounin at mdounin.ru>:
> Hello!
>
> On Wed, May 12, 2010 at 11:09:12PM +0200, Grzegorz Sienko wrote:
>
>> Hi.
>>
>> I'm trying to do some rewrite. My url is:
>> http://domain.tld/stream/file/{username}{crc_username}{hash-file}.{extension}
>> and I'm want it to rewrite it to different location, where files physically are.
>>
>>         location ^~ /stream/file/ {
>>                 rewrite
>> "([a-f0-9]{8})([a-f0-9]{8})([a-f0-9]{40})(\.[^\.\/\\]*)$?"
>
> - "([a-f0-9]{8})([a-f0-9]{8})([a-f0-9]{40})(\.[^\.\/\\]*)$?"
> + "([a-f0-9]{8})([a-f0-9]{8})([a-f0-9]{40})(\\.[^./\\\\]*)?$"
>
> nginx uses '\' as escape character in it's config syntax, and it
> should be doubled if you want to pass it literally.
>
> (and you don't need '\' before '.' in character group; and don't
> need '\' before '/'; and '?' can't follow '$')
>
> [...]
>
>> and while testing configuration I got error:
>> [emerg]: pcre_compile() failed: missing terminating ] for character
>> class in "([a-f0-9]{8})([a-f0-9]{8})([a-f0-9]{40})(\.[^\.\/\]*)$?"
>>
>> And I don't see why I missed one ] ? When I add ] to the end I got
>> error: pcre_compile() failed: missing terminating ).
>
> Regexp printed in error message is a hint.
>
> Maxim Dounin
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx
>



More information about the nginx mailing list