【发布时间】:2020-12-28 02:20:17
【问题描述】:
我在 Ubuntu 中使用 Apache2 作为 Web 服务器,我的根目录是 /var/www/html。在那里我有一个 .htaccess 文件与
RewriteEngine on
ErrorDocument 404 /custom404.html
在里面。这行得通。当我访问 mydomain.com/arandomstring 时,我看到了 custom404.html 页面。但是,我想要做的是阻止对 custom404.html 的直接访问,例如 domain.com/custom404.html 应该不起作用。我将如何实现这一目标?我对 StackOverflow 进行了广泛的搜索,但在这方面没有找到任何帮助。
【问题讨论】:
-
您是否在错误文档上尝试过 LocationMatch 并拒绝所有人?您拥有的 ErrorDocument 似乎是内部重定向。
标签: linux apache .htaccess ubuntu http-status-code-404