October 11, 2012 03:59PM
Hi Francis,

Thanks for introducing me to rewrite directive. Just to confirm, this is how I should use your rewrite:

root /home/www/example;

location /public/doc/ {
rewrite (.*)/(.*) $1/$2/$2.html break;
}

Ideally, for the other cases you raised, I want the following to happen:

>http://www.example.com/public/doc/abc123
>http://www.example.com/public/doc/abc123?para=nodata

when the query string (e.g. ?para=blah) part is missing or incomplete, I want to serve a generic error page (e.g. /error.html)

>http://www.example.com/public/doc/abc123/abc123.html

when the user tries to access the actual html page directly, I want to block it by either returning a 404 or serving a generic error page as above

>http://www.example.com/public/doc/one/two

when the user queries an URI that has no corresponding .html file on the server, I want to simply return a 404.

Can all these be implemented using rewrite only? Thanks.
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: 135
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready