簡體   English   中英

Nginx:如何在一個位置內重定向一個位置?

[英]Nginx: How to redirect a location within a location?

我正在嘗試將http://test.com/supporthttp://test.com/support/重定向到https://support.test.com ,並且我需要重定向http://test.com/support/*https://support.test.com/*

這是我現在擁有的代碼,它完成了下半年,但沒有上半年……任何想法都將有所幫助。

    location /support {
            proxy_pass         http://support.test.com;
            proxy_set_header Host "support.test.com";
            proxy_redirect off;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

我認為在位置塊中必須有if語句,但我不是100%肯定的。

您是否嘗試過將位置更改為這樣的正則表達式?

location ~* ^/support(?:/|\z) {
        proxy_pass ...
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM