【问题标题】:How to try other HTTP Error besides Error 404 using localhost如何使用 localhost 尝试除错误 404 之外的其他 HTTP 错误
【发布时间】:2016-04-25 11:54:08
【问题描述】:

使用localhost 服务器(wamp/xampp),是否可以尝试模拟大多数HTTP 错误(400,401,402,500,503(...))?

我已经使用 .htaccess 和 PHP 完成了自定义错误页面,但我只能测试错误 404。其他错误呢?

【问题讨论】:

    标签: php .htaccess localhost http-error


    【解决方案1】:

    PHP 中有一个名为header 的函数。

    查看文档https://secure.php.net/manual/en/function.header.php

    使用它,您可以向浏览器发送 HTTP 标头。

    或者如果你有 PHP5.4 或更高版本,你可以使用这个:

    http://www.php.net/manual/en/function.http-response-code.php

    【讨论】:

    • 好吧@paski你能帮我指定如何使用该函数,例如如果错误404将得到与输入url相同的结果localhost/web/notexist.php
    • @MerekaBilang 全部在手动链接中,检查那里的 cmets。
    猜你喜欢
    • 2018-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-19
    • 2019-09-18
    • 2019-06-13
    • 2023-03-10
    • 1970-01-01
    相关资源
    最近更新 更多