nginx - /etc/nginx/nginx.conf:9 中“try_files”指令中的参数数量无效
问题描述
我是 Nginx 服务器的新手,但是在重新加载 Nginx 后我正在关注官方文档,我遇到了这个警报:
invalid number of arguments in "try_files" directive in /etc/nginx/nginx.conf:9
这是我的 nginx.conf 文件:
events{}
http{
include /etc/nginx/mime.types;
server{listen 80;
server_name x.x.x.x;
root /var/www/html/;
try_files /error;
location =rediect {return 307 http://www.facebook.com;}
location /error {return 200 "we overcome the error ";}
location =/right{ return 200 "you are right"; }
location =/time{return 200 "$time_local";}
location =/host{return 200 "$hostname";}
location =/redirect{return 301 http://www.facebook.com;}
#location / {access_log /var/log/nginx/new.log;}
location / {access_log /var/log/nginx/last.log ;}
}
}
**Where is x.x.x.x is my machine ip.**
解决方案
习惯于阅读文档,尤其是像这样直截了当的问题。我知道你是 nginx 的新手,但谷歌搜索“nginx try_files”会比在这里输入问题要快得多。
无论如何,你会在这里结束:
http://nginx.org/en/docs/http/ngx_http_core_module.html#try_files
语法:try_files 文件 ... uri;
按指定顺序检查文件是否存在,并使用第一个找到的文件进行请求处理;处理在当前上下文中执行。文件的路径是根据根和别名指令从文件参数构造的。可以通过在名称末尾指定斜杠来检查目录是否存在,例如“$uri/”。如果没有找到任何文件,则内部重定向到最后一个参数中指定的 uri。
推荐阅读
- angular - Angularfire2 如何使用 AngularFireList 检索一项
- linux - Apache:在 VirtualHost 部分中动态设置 DocumentRoot?
- python - 使用 pymupdf 在 Pdf 中用图像名称替换图像
- c# - c# web应用程序| 网页被冻结 - 没有加载
- amazon-web-services - AWS Golang SDK - 如何将 DeleteOnTermination 放在 EBS 卷上?
- r - 尝试预测 lm 模型时的因子错误
- python - 分而治之的最近点问题
- pytorch - 拥抱脸伯特显示准确度差/ f1 分数 [pytorch]
- python - 在 Mac 上更改背景的 Python 最简单方法
- java - Recyclerview在Android中无需滚动即可使用淡入淡出效果转到位置