1

我正在尝试使用 Nginx 重写 URL,以下是输入和预期输出。

输入:http://localhost/test/studentinfo/DocumentViewer?studentName=ABC&age=25&SchoolName=TREDS&city=HYD

预期输出:http://localhost/student?studentName=ABC&city=HYD

因此,每当我尝试重写 URL 时,我都会在实际替换的 URL 后面获得整个参数 URL,如下所示。

我的重写逻辑:

rewrite ^/test/* /student?studentName=$arg_studentName&city=$arg_city permanent;

但我收到的输出是: http://localhost/student?studentName=ABC&city=HYDstudentName=ABC&age=25&SchoolName=TREDS&city=HYD

关于我犯了什么错误以及如何实现输出的任何想法。

谢谢!

4

1 回答 1

0

您缺少尾随?以防止rewrite附加原始参数。

例如:

rewrite ^/test/ /student?studentName=$arg_studentName&city=$arg_city? permanent;

有关详细信息,请参阅此文档

于 2018-08-17T11:59:51.767 回答