php - Heroku HTTP 响应代码 200,应该是 404
问题描述
我有一个网站,我目前正在另一个网络托管服务上运行,我正试图转移到 heroku。我有一个处理错误的系统,其中包含以下文件:
.ht 访问:
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^([^\.]+)$ $1.php [NC,L]
DirectoryIndex /home.php
ErrorDocument 400 /error.php
ErrorDocument 401 /error.php
ErrorDocument 403 /error.php
ErrorDocument 404 /error.php
ErrorDocument 500 /error.php
ErrorDocument 503 /error.php
错误.php:
<?php
$httpc = http_response_code();
echo "Your http code is ".$httpc;
?>
例如,如果您访问一个不存在的页面,它会加载 error.php 并显示“您的 http 代码是 404”。只有它没有,它说我有一个 200 OK 代码。虽然在旧主机上,它工作得很好?heroku 处理错误的方式有什么不同还是我错过了什么?
错误页面:http
://ankhsite.herokuapp.com/error.php
测试 404 错误:http ://ankhsite.herokuapp.com/thisdoesnotexist
编辑:我也刚刚意识到这一点,但在 heroku 日志中我什至可以直观地看到它给出了 404 错误。
解决方案
推荐阅读
- javascript - 为什么当我要求它运行十次时它只打印一次而不是十次
- android - 如何防止状态栏覆盖nativescript中的模态页面
- python - 给定操作的优化,有没有更好的方法?
- javascript - 如何从选项表单中更改图表?
- android - 添加隐式广播异常?
- php - 仅允许附加的身份验证用户 [课程所有者] 访问课程查看页面 [LARAVEL 政策]
- scala - 用于分区过滤的 Spark 目录查找可以并行吗?
- reactjs - 功能性 React 组件生命周期
- jenkins - 在 Jenkins 中归档文件时如何保持文件夹结构?
- ksqldb - PUSH查询期间的KSQLDB java客户端错误