String replace on rewrite module

Alex Sergeyev asergeyev at dyn.com
Tue Jul 20 17:35:22 MSD 2010


JBruni,

Eventually you'll need something like:

rewrite ^(/.*)/(.*)/(.*)/image/(.*)$  $1_$2_$3/$4 break;

More info available at: http://wiki.nginx.org/NginxHttpRewriteModule


Alex.




On Tue, 2010-07-20 at 09:22 -0400, jbruni wrote:
> My goal is simple. Rewrite the following URL:
> 
> [b]http://example.com/path/to/folder/image/picture1.jpg[/b]
> 
> to
> 
> [b]http://example.com/image/path_to_folder/picture1.jpg[/b]
> 
> My doubt is: how can I transform [b]path/to/folder[/b] into
> [b]path_to_folder[/b]?
> 
> In fact, all I want to know is how to [b]substitute the forward slashes
> "/" by underscores "_"[/b]
> 
> The path/to/folder can be nested in unknown levels (as in
> path/to/a/very/deep/level/folder )
> 
> Is there a "string replace" function in rewrite module to do this? Or
> something else?
> 
> Thanks!
> 
> Posted at Nginx Forum: http://forum.nginx.org/read.php?2,110833,110833#msg-110833
> 
> 
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://nginx.org/mailman/listinfo/nginx





More information about the nginx mailing list