.htaccess 重定向文件扩展到错误页面

.htaccess redirect file with extensions to error page

在开始提问之前,我想说的是我尝试到处搜索,但没有找到任何东西,所以...

我的问题是我想更改 first.html second.html 等到没有扩展名的第一秒,我使用这个:

Options +MultiViews

现在我的文件没有扩展名,现在我希望当有人写 first.html 或 second.html 时将其发送到错误页面,现在我的代码如下:

ErrorDocument 404 errore/errore.html

Options +MultiViews

希望你能帮助我。

尝试添加:

RewriteCond %{THE_REQUEST} \ /+[^\?]+\.(html|php)
RewriteRule ^ - [L,R=404]

此重写规则(如果您的 htaccess 文件中还没有,则需要 RewriteEngine On)将直接请求匹配到任何以扩展名 .html 或 [=13] 结尾的内容=] 并使用 R=404 重写标志将请求标记为 404 响应。