如何将 404 和 403 网页更改为本地主机中的自定义页面?

How to change 404 and 403 web pages to custom pages in localhost?

我想自定义 403 和 404 错误页面? (.htaccess 文件或代码)

考虑到 Apache 在站点的根目录中查找指定文档这一事实,在 .htaccess 文件中添加以下代码。

 ErrorDocument 404 /test/404.html // 404 page path

在 .htaccess 文件中加入这一行。

 ErrorDocument 403 /403.php
 ErrorDocument 404 /404.php

如果您的网站位于子文件夹中,则

 ErrorDocument 403 /subFolderName/403.php
 ErrorDocument 404 /subFolderName/404.php