gpt4 book ai didi

redirect - 如何在nginx中使用参数重定向url

转载 作者:行者123 更新时间:2023-12-05 03:10:51 24 4
gpt4 key购买 nike

例如,我想从 https://www.example.com/ 重定向${pid}.txt 到 http://www.anotherExample.com/api?pid= ${pid}如何在nginx中配置它?提前致谢:)

最佳答案

试试这个:

server {

listen 443;
server_name www.example.com;

location ~* ^/(.+)\.txt$ {
return 301 http://www.anotherexample.com/api?pid=$1;
}

}

如果您的 pid 具有特定格式(例如只有数字),则将 (.+) 替换为适当的模式。

如果您想在不重定向的情况下显示内容,请将 return 301 替换为 proxy_pass

关于redirect - 如何在nginx中使用参数重定向url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38517948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com