Welcome! Log In Create A New Profile

Advanced

Re: URI re-mapping using try_files

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.
SubjectAuthorPosted

URI re-mapping using try_files

mrtnOctober 11, 2012 09:19AM

Re: URI re-mapping using try_files

Francis DalyOctober 11, 2012 12:58PM

Re: URI re-mapping using try_files

mrtnOctober 11, 2012 03:59PM

Re: URI re-mapping using try_files

Francis DalyOctober 11, 2012 04:34PM

Re: URI re-mapping using try_files

mrtnOctober 11, 2012 05:22PM

Re: URI re-mapping using try_files

Francis DalyOctober 11, 2012 06:14PM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 84
Record Number of Users: 7 on March 06, 2014
Record Number of Guests: 165 on April 21, 2014
Powered by nginx    Powered by FreeBSD    PHP Powered    Powered by Percona     ipv6 ready