我正在嘗試為使用引數指向資料的 CDN 系統構建一個重寫。所有資料都存盤在同一位置,因此任何重寫都需要通配符重寫 $arg_name,然后傳遞資料的值。轉這個:
http://cdn.example.com/data/?main_loc=datastring
進入這個:
http://example.com/datastore/datastring
使用位置指令,我可以將請求獲取到 /data/,但從那里我不知道重寫需要什么樣的外觀才能執行“匹配任何 arg 名稱”,如 main_loc、backup_loc 等,以將其值傳遞為改寫。我可以應用正則運算式來匹配任何 $arg_name 并使用其中的值嗎?
location ^~ /data/ {
rewrite ^$arg_(\w*\_\w*)$ http://example.com/datastore/$1;
}
或者那會是什么樣子?
uj5u.com熱心網友回復:
您可以使用以下映射捕獲 arg 值:
map $args $arg_value {
~=(.*) $1;
}
然后重定向到它:
location = /data/ {
return 301 http://example.com/datastore/$arg_value;
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/463105.html
上一篇:cv2.connectedComponentsWithStats源代碼
下一篇:另一個指向陣列問題的C 指標
