gpt4 book ai didi

Nginx 未知指令 "if($domain"

转载 作者:行者123 更新时间:2023-12-03 22:46:27 25 4
gpt4 key购买 nike

Nginx 提示我的配置的以下部分:

nginx: [emerg] unknown directive "if($domain" in /etc/nginx/nginx.conf:38
nginx: configuration file /etc/nginx/nginx.conf test failed

这是它正在谈论的一点:
server_name ~^(?:(?<subdomain>\w*)\.)?(?<domain>\w+)\.(?<tld>(?:\w+\.?)+)$;

if($domain = "co") {
set $domain "${subdomain}";
set $subdomain "www";
set $tld "co.${tld}";
}

if ($subdomain = "") {
set $subdomain "www";
}
root /var/www/sites/$domain.$tld/$subdomain;

location / {
index index.php index.html index.htm;
}

这是我的配置文件的完整服务器部分:
server {
listen 80;
server_name ~^(?:(?<subdomain>\w*)\.)?(?<domain>\w+)\.(?<tld>(?:\w+\.?)+)$;

if($domain = "co") {
set $domain "${subdomain}";
set $subdomain "www";
set $tld "co.${tld}";
}

if ($subdomain = "") {
set $subdomain "www";
}
root /var/www/sites/$domain.$tld/$subdomain;

location / {
index index.php index.html index.htm;
}
}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}

问题是什么?

最佳答案

希望您现在已经解决了这个问题,但对于其他正在努力解决类似问题的人。您需要在 if 语句和左括号之间包含一个空格。

因此,在您的示例中,您需要更改行

if($domain = "co") {


if ($domain = "co") {

一切都应该正常工作。

关于Nginx 未知指令 "if($domain",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20286369/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com