簡體   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