rewriting a filename in any directory

Aaron bompus at gmail.com
Fri Jan 23 09:31:01 MSK 2009


I am trying to achieve the following:

Request: http://www.domain.com/images/afv-585785-something.gif
Would normally retrieve from : /public/images/afv-585785-something.gif

I need it to actually retrieve : /public/images/something.gif

So basically it needs to remove the "afv-######-" portion from the file request.

I am doing this for cache/expire versioning purposes. I tried the
following but it only works on the root folder and not subdirectories.

location / {
rewrite ^(.*)/afv-(.*)-(.*)$ $1/$3 last;
}

What am I doing wrong?

Thanks,
Bompus





More information about the nginx mailing list