开发者社区> 问答> 正文

nginx怎么设置404页面啊?求教

nginx怎么设置404页面啊?求教
我试了试这个不行啊、、、 http://phpwind.me/300.html   不知道是写的不对还是则呢么回事

展开
收起
ap1202k3m 2012-06-27 21:18:23 7290 0
2 条回答
写回答
取消 提交回答
  • 参考官方提供的文档: http://wiki.nginx.org/HttpCoreModule#error_page

    error_page
    Syntax:    error_page code ... [ = [ response ]] uri
    Default:    
    Context:     http
    server
    location
    if in location
    Reference:    error_page

    The directive specifies the URI that will be shown for the errors indicated.

    Example:

    error_page   404          /404.html;
    error_page   502 503 504  /50x.html;
    error_page   403           http://example.com/forbidden.html;
    error_page   404          = @fetch;
    Furthermore, it is possible to change the status code of the answer to another, for example:

    error_page 404 =200 /empty.gif;
    error_page 404 =403 /forbidden.gif;
    Additionally you can have your designated error handler determine the returned status code by using = without specifying a status code.

    error_page   404 = /404.php;
    If there is no need to change URI during redirection it is possible to redirect processing of error pages into a named location:

    location / (
        error_page 404 @fallback;
    )

    location @fallback (
        proxy_pass http://backend;
    )
    2012-06-28 20:58:19
    赞同 展开评论 打赏
  • 我也不太懂
    2012-06-28 11:41:50
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
《Nginx 代理系统常用手册》 立即下载
CentOS Nginx PHP JAVA 多语言镜像使用手 立即下载
CentOS Nginx PHP JAVA多语言镜像使用手册 立即下载