Nginxhttp模块(三)
来源:百度文库 编辑:神马文学网 时间:2024/04/29 04:33:12
Error_page
语法: error_page code [code …] [=\=answer-code] uri
默认值:no
Context:http,server,location
URI指定了为特定的错误码显示的页面
e.g.
error_page 404 /404.html;
error_page 502 503 504 /50x.html;
error_page 403 http://example.com/forbidden.html;
Furthermore, it is possible to change the code of answer to another, for example:
error_page 404 =200 /.empty.gif;
If an erroneous answer is processed by the proxied or FastCGI server and this server can return the different answer codes, for example, 200, 302, 401 or 404, then it is possible to issue the code returned:
若错误应答由代理或fastCGI服务器处理的话就可返回不同的错误应答码
error_page 404 = /404.php;
index
语法:index file [file…]
默认值:index.html index
Context:http,server,location
指定索引文件,在文件名中可以使用变量,检测顺序由列举出的文件顺序决定,可以将一个含有绝对路径的文件放到最后
使用变量的例子
index index.$geo.html index.0.html /index.html;
internal
语法:internal
默认值:no
Context:location
此指令使得匹配location仅仅为称为“internal”的request所使用,如果是外部请求则返回“not found”的错误。
内部请求包括
- requests redirected by the instruction error_page :由error_page重定向的请求
- subrequests created by the command include virtual of the "ngx_http_ssi_module" module 由ngx_http_ssi_module的include virtual命令所产生的子请求
- requests changed by the instruction rewrite of the "ngx_http_rewrite_module" module 由ngx_http_rewrite_module的rewrite命令修改的请求。
阻止client直接获得error_page的例子
Error_page 404 /404.html
Location /404.html {
Internal;
}