Nginx redirect without scheme and hostname

Viewed 1659

I have used return or rewrite in Nginx to redirect, but both will redirect with the http header Location which has value of the full url, but I want it just value the path.

for example:

return 301 /test;

or

rewrite ^/$ /test permanent;

will has the Location value of
http://www.example.com/test

but I want it be just
/test

I wonder if it is possible.


Solved.
as of 1.11.8, just set the directive(Thanks to @RichardSmith):

absolute_redirect off;

before 1.11.8, I find a wonderful answer(Thanks to @xiaochen):
https://stackoverflow.com/a/39462409

0 Answers
Related