如果我连接www.my-hsot.com
,那么请始终输出'您好!'文本..
但是我的index.html文件内容一无所获。我只想要空白页.. 我该如何修改默认索引文件?
这是我的默认配置:
server {
listen 80;
root /home/me;
index index.php index.html index.htm;
server_name www.my-hsot.com;
location / {
try_files $uri $uri/ /index.php?$request_uri;
}
location /.well-known {
root /home/me/well-known;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_keep_conn on;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
}
}
这是nginx默认索引文件(路径:/usr/share/nginx/html/index.html):
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
答案 0 :(得分:2)
您已设置
root /home/me;
index index.php index.html index.htm;
...
location / {
try_files $uri $uri/ /index.php?$request_uri;
}
因此,当访问/ nginx时,首先会查找传递给fcgi处理程序的index.php。我猜那就是“你好!”来自:index.php。
如果没有index.php,它会查找index.html,但是在文件root / home / me中。
要获得空白页/您可以使用类似
的内容location ~ "^[/]?$" {
return 200;
}