Url rewrite for restful url

Francis Daly francis at daoine.org
Wed Aug 8 23:57:59 UTC 2012


On Wed, Aug 08, 2012 at 08:30:57PM +0200, Edward Stembler wrote:

Hi there,

> /projects/1/attachments/some_file.xls
> 
> I want to setup Nginx to redirect to the static file on the server:
> 
> /public/attachments/1/some_file.xls
> 
> Where 1 is the dynamic project id.

If you want requests like /projects/N/attachments/F to return the content
of the file /public/attachments/N/F, then "alias" is probably the way
to go.

http://nginx.org/r/alias

  location ~ ^/projects/(\d+)/attachments/(.*) {
    alias /public/attachments/$1/$2;
  }

Good luck with it,

	f
-- 
Francis Daly        francis at daoine.org



More information about the nginx mailing list