<div dir="ltr">Hi Maxim, thanks for the rewrite_log hint.<div>Actually it does rewrite as expected:</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">2019/06/21 12:35:37 [notice] 7495#7495: *4693835 "(?i)^/ambassadors$" matches "/ambassadors", client: 1.1.1.1, server: <a href="http://www.example.co.uk">www.example.co.uk</a>, request: "GET /ambassadors?test=1 HTTP/1.1", host: "<a href="http://www.example.co.uk">www.example.co.uk</a>"<br>2019/06/21 12:35:37 [notice] 7495#7495: *4693835 rewritten redirect: "<a href="https://www.example.com/uk-en/experience/ambassadors/">https://www.example.com/uk-en/experience/ambassadors/</a>", client: 93.46.189.23, server: <a href="http://www.example.co.uk">www.example.co.uk</a>, request: "GET /ambassadors?test=1 HTTP/1.1", host: "<a href="http://www.example.co.uk">www.example.co.uk</a>"</blockquote><div><br></div><div>but i still get the response as above.</div><div>So i suspect the culprit may be varnish, saving the QS in be.req and re-adding the QS in be.resp .</div><div>I see no other explanation.</div><div><br></div><div>Thanks!</div><div><br></div><div><br></div><div><br></div><div><br></div><div> </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 20, 2019 at 5:21 PM Maxim Dounin <<a href="mailto:mdounin@mdounin.ru">mdounin@mdounin.ru</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello!<br>
<br>
On Thu, Jun 20, 2019 at 05:05:57PM +0200, aquilinux wrote:<br>
<br>
> Hi guys, i've always used ? to strip QS in rewrites but i cannot get past<br>
> this odd issue i'm having:<br>
> <br>
> URL SOURCE:<br>
> <br>
> > <a href="https://www.example.co.uk/ambassadors?test=1" rel="noreferrer" target="_blank">https://www.example.co.uk/ambassadors?test=1</a><br>
> <br>
> <br>
> REWRITE:<br>
> <br>
> > rewrite (?i)^/ambassadors$<br>
> > <a href="https://www.example.com/uk-en/experience/ambassadors/" rel="noreferrer" target="_blank">https://www.example.com/uk-en/experience/ambassadors/</a>? permanent;<br>
> <br>
> <br>
> OR EVEN:<br>
> <br>
> > location ~* ^/ambassadors$ {<br>
> >   rewrite (.*) <a href="https://www.example.com/uk-en/experience/ambassadors/" rel="noreferrer" target="_blank">https://www.example.com/uk-en/experience/ambassadors/</a>?<br>
> > permanent;<br>
> > }<br>
> <br>
> <br>
> RESULT WITH REWRITE:<br>
> <br>
> > [~]> curl -kIL <a href="https://www.example.co.uk/ambassadors?test=1" rel="noreferrer" target="_blank">https://www.example.co.uk/ambassadors?test=1</a><br>
> > HTTP/2 301<br>
> > date: Thu, 20 Jun 2019 14:44:21 GMT<br>
> > content-type: text/html<br>
> > location: <a href="https://www.example.com/uk-en/experience/ambassadors/?test=1" rel="noreferrer" target="_blank">https://www.example.com/uk-en/experience/ambassadors/?test=1</a><br>
> > x-who: SVAORMG2V01<br>
<br>
An nginx response is expected to contain "server: <br>
nginx/<version>", for example:<br>
<br>
$ curl -kI <a href="https://127.0.0.1:8443/ambassadors?test=1" rel="noreferrer" target="_blank">https://127.0.0.1:8443/ambassadors?test=1</a><br>
HTTP/2 301 <br>
server: nginx/1.17.1<br>
date: Thu, 20 Jun 2019 15:11:51 GMT<br>
content-type: text/html<br>
content-length: 169<br>
location: <a href="https://www.example.com/uk-en/experience/ambassadors/" rel="noreferrer" target="_blank">https://www.example.com/uk-en/experience/ambassadors/</a><br>
<br>
Are you sure the response you've provided is from nginx?<br>
<br>
(Also, as you can see from the above example response, the rewrite <br>
is working fine.)<br>
<br>
You may also want to drop "-L" from your curl options to make sure <br>
you are looking at a particular response, and not a chain of <br>
redirects.<br>
<br>
If the above doesn't help, you may consider using "rewrite_log on;" <br>
to find out how your rewrites are processed (see <br>
<a href="http://nginx.org/r/rewrite_log" rel="noreferrer" target="_blank">http://nginx.org/r/rewrite_log</a> for details).<br>
<br>
-- <br>
Maxim Dounin<br>
<a href="http://mdounin.ru/" rel="noreferrer" target="_blank">http://mdounin.ru/</a><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 clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">"Madness, like small fish, runs in hosts, in vast numbers of instances."<div><br></div><div><div>Nessuno mi pettina bene come il vento.</div></div></div></div>