问题描述
如何为域名设置index.html,例如 - 将用户引导到根目录中的index.html。
我已经试过喜欢不同的东西:
How to set index.html for the domain name e.g. https://www.example.com/ - leads user to index.html in root directory.I've tried different things like:
server {
# some configs
location = / {
index index.html;
fastcgi_index index.html;
}
or
location / {
index index.html;
fastcgi_index index.html;
}
}
没有什么帮助了我。
还有一些其他配置与location关键字,虽然我也评论过他们。 。| HTC | JS | BMP
nothing helped me.There are some other configs with location keyword, though I'd commented them either.Other "location" configs in server { clause:
location ~ .*(css|htc|js|bmp|jp?g|gif|ico|cur|png|swf|htm?|html)$ {
access_log off;
root $www_root;
}
location ~ \.php$
{
include /etc/nginx/fastcgi_params;
index index.html;
fastcgi_index index.html;
fastcgi_param SCRIPT_FILENAME $www_root$fastcgi_script_name;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass 127.0.0.1:9000;
# Директива определяет что ответы FastCGI-сервера с кодом больше или равные 400
# перенаправлять на обработку nginx'у с помощью директивы error_page
fastcgi_intercept_errors on;
break;
}
location ~ /\.ht {
deny all;
}
所有这些都注释掉和取消注释,但没有任何帮助。
All them were commented and uncommented, but nothing helped.
PS版是在/etc/nginx/sites-enabled/domainname.com文件的。
PS Editions were made in /etc/nginx/sites-enabled/domainname.com file.
推荐答案
答案是将根目录放置到位置指令:
The answer is to place the root dir to the location directives:
root /srv/www/ducklington.org/public_html;
这篇关于nginx - 如何设置index.html作为根文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!