小编use*_*440的帖子

PHP 中的自定义 404 错误页面

我是PHP新手,希望你能帮我解决这个问题。如何在 PHP 中创建自定义 404 错误页面而不去任何地方或将其重定向到其他页面。

前任。 mysite.com/no-where

该页面no-where不存在。我想在该 URL 上显示带有设计的 404 错误消息。

如何获取当前 URL?我有一个错误。因为我想检查标题是否为 404。

$url = $_SERVER['REQUEST_URI'];
$array = get_headers($url);
$string = $array[0];
if(strpos($string,"200")) {
    echo 'url exists';
} else {
    echo 'url does not exist';
}
Run Code Online (Sandbox Code Playgroud)

php .htaccess http-status-code-404

3
推荐指数
1
解决办法
1万
查看次数

标签 统计

.htaccess ×1

http-status-code-404 ×1

php ×1