URI re-mapping using try_files
Francis Daly
francis at daoine.org
Thu Oct 11 22:12:37 UTC 2012
On Thu, Oct 11, 2012 at 05:22:54PM -0400, mrtn wrote:
Hi there,
> >I guess (without testing):
> >
> >if ($arg_para != data) { return 404; }
> >
> >inside that location{} would probably work
>
> Hmm, I read on nginx website and elsewhere that if statement may not work
> consistently within a location directive, and is generally discouraged.
> Should I worry in this case?
What precisely did you read? And does it apply here?
(I think I know the answers to those; but there's no reason for you to
believe my words instead of words written elsewhere. If the words are
all consistent, then you can choose to believe them all. If the words are
contradictory, then you must choose which source to consider incorrect.)
> >(As in: do you repeat everything after /public/doc, or do you repeat
> >just the final after-slash part?)
>
> I only want to repeat the final after-slash part, so any
> '/public/doc/blahA/blahB' should only look for
> '/public/doc/blahA/blahB/blahB.html'. Would that change anything in the
> config proposed here?
What happened when you tried it?
mkdir -p /home/www/example/public/doc/blahA/blahB/blahA
echo This is in blahB > /home/www/example/public/doc/blahA/blahB/blahB.html
echo This is in blahA > /home/www/example/public/doc/blahA/blahB/blahA/blahB.html
curl -i http://www.example.com/public/doc/blahA/blahB
As it happens, the rewrite suggested should end up fetching the "in blahB"
file, because it only repeats the part after the last slash.
When you understand *why* it does that, you'll have a better chance of
writing your own regex-based rewrites.
Good luck with it!
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list