<div dir="ltr"><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">Your PCRE is not right. You might interpret it in more 'natural' language as:<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)"><start>/api/app/<anything but '/'>/<anything but '/'>/<anything but '/' or nothing><end><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">The URI /api/app/login does not match it.<br><br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">You have several ways of addressing that:<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">- Rewrite you huge, do-it-all PCRE, adding optional, non-capturing groups<br></div><div class="gmail_default" style="font-size:small;color:rgb(51,51,153)">- Split the rewriting rule in several versions, each addressing one depth level (eases readibility/maintenance/performance?)<br></div><div class="gmail_extra"><br>I would also suggest you avoid using rewrite and replace it with location/return as much as you could:<br><a href="https://youtu.be/YWRYbLKsS0I">https://youtu.be/YWRYbLKsS0I</a><br clear="all"><div><div class="gmail_signature"><font size="1"><span style="color:rgb(102,102,102)">---<br></span><b><span style="color:rgb(102,102,102)">B. R.</span></b><span style="color:rgb(102,102,102)"></span></font></div></div>
<br><div class="gmail_quote">On Mon, Jul 13, 2015 at 12:17 PM, Ben <span dir="ltr"><<a href="mailto:ben+nginx@list-subs.com" target="_blank">ben+nginx@list-subs.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
Am suffering with a bit of writer's block when it comes to query rewrites.<br>
<br>
I've got a rewrite rule that looks like :<br>
<br>
rewrite ^/api/app/([^/]+)/([^/]+)/([^/]+)?$ /api/app/$1.php?p=$2&q=$3? last;<br>
<br>
I am having two problems :<br>
<br>
- I am getting 404 when I try to make a POST call to /api/app/login, I have to use the full suffix, i.e. api/app/login.php instead.<br>
<br>
- I want to make the last ([^/]+) optional, but seem to also be getting the same 404 if I forget to include it ?<br>
<br>
Ideas most welcome, thanks !<br>
<br>
_______________________________________________<br>
nginx mailing list<br>
<a href="mailto:nginx@nginx.org" target="_blank">nginx@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx</a><br>
</blockquote></div><br></div></div>