【问题标题】:nginx: error_page doesn't work with rewritenginx:error_page 不适用于重写
【发布时间】:2017-09-05 20:29:50
【问题描述】:

我有这个 nginx 配置文件:

server {
    listen 80;
    server_name tds.my;
    root /home/tds;
    index index.php;
    error_page 500 502 503 504 /errs/50x.html;
    error_page 400 401 402 403 404 /errs/404.html;

    if ( $request_uri !~ "/errs|index\.php" ) {
            rewrite ^(.+)$ /index.php last;
    }

    location ~ .php$ {
            fastcgi_intercept_errors on;
            fastcgi_index index.php;
            fastcgi_pass unix:/tmp/php-fcgi.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }

}

index.php 生成状态为 500 的错误。 链接http://tds.my/index.php 返回静态页面http://tds.my/errs/50x.html,但链接http://tds.my/example.php 不返回静态页面。我认为这是因为使用了重写。

如何配置 nginx 来解决这个问题?

【问题讨论】:

    标签: nginx url-rewriting


    【解决方案1】:

    请查看指令recursive_error_pages,它对我有用。感谢Jim D。

    【讨论】:

      猜你喜欢
      • 2013-10-20
      • 1970-01-01
      • 2012-12-01
      • 2016-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-07-27
      • 2019-09-04
      相关资源
      最近更新 更多