我目前在域名 khairulslt.me(来自 NameCheap)上有一堆可用的静态文件。最近,我尝试设置一个子目录(khairulslt.me/RGBGame),如下面的代码所示;但是,我一直收到 404 错误。我错过了什么?
server {
server_name khairulslt.me www.khairulslt.me;
autoindex off;
location / {
root /var/www/khairulslt.me;
index circles.html;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/khairulslt.me/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/khairulslt.me/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
location /RGBGame {
root /var/www/khairulslt.me/RGBGame;
index colorGame.html;
try_files $uri $uri/ /var/www/RGBGame/colorGame.html?q=$uri&$args;
autoindex off;
}
location /robots.txt { return 200 "User-agent: *\nDisallow: /\n";
}
}
server {
if ($host = www.khairulslt.me) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = khairulslt.me) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name khairulslt.me www.khairulslt.me;
return 404; # managed by Certbot
}
我尝试了所有不同的设置,例如(别名 vs root)、try_files、autoindex(开启、关闭)。我的主要网站 www.khairulslt.me 运行良好,并且完全可以正常提供 /var/www/khairulslt.me 中的 html/css/js 文件。我只是不确定为什么我无法为我的其他应用程序复制设置(文件夹 /RGBGame 中的 html/css/js 文件)。可能是我遗漏了与 nginx 配置无关的内容?