Nginx 从变量或任何字符串中提取值 [英] Nginx extract a value from a variable or any string
本文介绍了Nginx 从变量或任何字符串中提取值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有使用 If 从 Nginx 配置文件中的变量中提取值的替代方法?
Is there an alternative of using If to extract a value from a variable in Nginx config files?
即
if ($http_referer ~* (?<=url=)([\w-.]*)(?=/) ){
set $proxied $1;
rewrite (?<=/)(.+\.(css|jpg|png|gif|js)) http://$proxied/$1 redirect;
}
谢谢
推荐答案
map $http_referer $proxied {
default example.com;
"~*(?<=url=)(?<p>[\w-.]*)(?=/)" $p;
}
这篇关于Nginx 从变量或任何字符串中提取值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文