【发布时间】:2022-01-11 01:19:31
【问题描述】:
我正在尝试为可能存在或不存在的文档或文件夹或文件或链接显示自定义 404 页面,但我仍想出于某种目的向访问者显示 404 消息。
我检查了Setting a custom 404 page for a specific URL in htaccess 和Setting a custom 404 page for a specific URL in htaccess
代码:
RewriteRule ^foo.html$ /spoof404.txt [L,R=404,NC]
RewriteRule ^hello$ /spoof404.txt [L,R=404,NC]
RewriteRule ^file/example.php$ /spoof404.txt [L,R=404,NC]
使用这些代码,我成功获得了404 Status in header,但它没有显示spoof404.txt 的内容
注意:
- 我不是在寻找像 404 或 403 这样的错误文档
- 我不是在寻找重定向
- 这不是重复的问题。在问这里之前,我已经搜索了 stackoverflow 的其他部分。
【问题讨论】:
标签: apache .htaccess mod-rewrite url-rewriting http-status-code-404