在 Lib/Action/ 建立 EmptyAction.class.php:
display("Public:404"); // 渲染 404 模板
}
}
?>
ErrorDocument 404 /404.html
放入 httpd.conf 或 .htaccess。
IIS 管理器 → 網站屬性 → 「自定義錯誤」→ 404 設置指向 /404.html 或 /404.asp。
PHP 環境建議用 .htaccess 或 web.config 配置:
自定義 404 頁面 (ASP/PHP) 須輸出狀態碼:
// PHP 404 頁面
if (/* 無結果 */) {
require('/404.php');
header('HTTP/1.1 404 Not Found');
header('Status: 404 Not Found');
exit;
}
<% Response.Status = "404 Not Found" %>