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

标签 nginx

我试图在 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/

相关文章:

phpmyadmin 停留在登录状态(nginx 服务器)

tomcat - 请求上下文路径 grails spring security

authentication - 如何在 nginx 中设置自动身份验证层?

Oracle PDO OCI 字符集失败

nginx - docker 不会在 nginx html 根目录中创建文件夹

nginx - 无法在 php.ini 中更改 upload_max_filesize 或 post_max_size

当 php-fpm 返回 500 时,Nginx 返回 502 错误

SSL 多个子域 您的连接不是私密的

javascript - Angular HTML5 模式和 ui-router 返回 403

nginx - 使用Nginx-ingress从外部kubernetes集群向RabbitMQ发送消息