please help me with follow rewrite rule.

António P. P. Almeida appa at perusio.net
Wed Oct 6 21:41:52 MSD 2010


On 6 Out 2010 17h50 WEST, nginx-forum at nginx.us wrote:

> here is the structure:
> /images/thumbnails/
> /watermark
>
> i use follow rewrite rule to add a watermark on my pictures.
>
> rewrite ^/images/(.*)\.jpg /wm/wm.php?$request_filename;
>
> i found it will rewrite with images/*.jpg and
> image/thumbnails/*.jpg, but actually i only wanna rewrite
> images/*.jpg, not subdirectories. then i change it to:
>
> rewrite ^/images/(.[^/])\.jpg
> /watermark/image.php?$request_filename;

You regex is incorrect. Furthermore since you're not doing any
capturing or using alternative patterns drop the group.

rewrite ^/images/[^/]*\.jpg /watermark/image.php?$request_filename;

It matches any file *only* under the images directory ending in .jpg.

--- appa




More information about the nginx mailing list