please help me with follow rewrite rule.

Maxim Dounin mdounin at mdounin.ru
Wed Oct 6 21:15:21 MSD 2010


Hello!

On Wed, Oct 06, 2010 at 12:50:29PM -0400, digginchina 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;

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

> my opinion is fit all character except "/" so that i can remove all
> subdirectories from the rewrite rule. 
> 
> but unfortunately, it doesn't work well, /images/*.jpg can't be rewrited
> too.
> 
> is there anybody help me with this case?

Recommended reading:
Jeffrey E.F. Friedl, "Mastering Regular Expressions"

And try pcre manpages, in particular 'man pcrepattern'.  Using 
pcretest to test things is good idea, too.

Maxim Dounin



More information about the nginx mailing list