繁体   English   中英

Nginx 根据 url 中包含的内容进行重定向

[英]Nginx Redirect based on what is contained in the url

在重定向和重写等方面,我是个菜鸟……我的目标是根据发送到服务器的内容进行重定向。 将发送的 URL 示例:

https://example.org/git/#123

https://example.org/git/!123

并重定向到 url 如果! 或 # 是其中的一部分,如果 ! then it would go to https://git.example2.com/userhere/repohere/merge_requests/123 if # then it would go to https://git.example2.com/userhere/repohere/issues/123

nginx 位置块的一些帮助会很好。

你无法匹配#123。 所以你需要使用不同的字符,即 &

使用以下示例规则。

if ($request_uri ~ "^(.*)/!123)"{
return 301 https://git.example2.com/userhere/repohere/merge_requests/123;
}
if ($request_uri ~ "^(.*)/!456)"{
return 301 https://git.example2.com/userhere/repohere/merge_requests/456;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM