Welcome! Log In Create A New Profile

Advanced

Re: URI re-mapping using try_files

Francis Daly
October 11, 2012 12:58PM
On Thu, Oct 11, 2012 at 09:19:23AM -0400, mrtn wrote:

Hi there,

> I use nginx to serve static html pages to users, and in particular, I want
> users who visit 'www.example.com/public/doc/abc123?para=data' to be served
> with the file '/home/www/example/public/doc/abc123/abc123.html' on the
> server, but 'www.example.com/public/doc/abc123?para=data' stays in the
> user's browser address bar.

For this sort of thing, "rewrite" (http://nginx.org/r/rewrite) is probably
the directive you want.

rewrite (.*)/(.*) $1/$2/$2.html break;

can do what you want in this case.

What do you want to happen if the user asks for any of:

http://www.example.com/public/doc/abc123
http://www.example.com/public/doc/abc123?para=nodata
http://www.example.com/public/doc/abc123/abc123.html
http://www.example.com/public/doc/one/two

The rewrite directive above may or may not do what you want for those.

> So there are two issues here: 1. map URI pattern '/public/doc/blah' to file
> '/home/www/example/public/doc/blah/blah.html' on the server; 2. keep query
> string '?parap=data' in the address bar.

1) is in the rewrite (or any similar configuration which maps url to file)

2) is by virtue of not doing an external rewrite, which is a redirection.

f
--
Francis Daly francis@daoine.org

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Subject Author Posted

URI re-mapping using try_files

mrtn October 11, 2012 09:19AM

Re: URI re-mapping using try_files

Francis Daly October 11, 2012 12:58PM

Re: URI re-mapping using try_files

mrtn October 11, 2012 03:59PM

Re: URI re-mapping using try_files

Francis Daly October 11, 2012 04:34PM

Re: URI re-mapping using try_files

mrtn October 11, 2012 05:22PM

Re: URI re-mapping using try_files

Francis Daly October 11, 2012 06:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 87
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready