gpt4 book ai didi

nginx - 如果 nginx conf 文件中的条件串联

转载 作者:行者123 更新时间:2023-12-04 13:22:06 25 4
gpt4 key购买 nike

我试图在 nginx conf 文件中执行此操作,但它不起作用:

if ($scheme://$host = 'http://example.com') {
return 301 https://example.com$request_uri;
}

那么如何在 if 条件下连接 $scheme 和 $host 呢?

最佳答案

使用临时变量很容易

set $tmp $scheme://$host;
if ($tmp = 'http://example.com') {
return 301 https://example.com$request_uri;
}

关于nginx - 如果 nginx conf 文件中的条件串联,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49867809/

25 4 0