String replace on rewrite module

jbruni nginx-forum at nginx.us
Tue Jul 20 17:22:30 MSD 2010


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




More information about the nginx mailing list