php - 自定义 404 错误页面——仅适用于 PHP 页面

标签 php apache .htaccess http-status-code-404

我有一个带有 htaccess 的 404 个性化页面

ErrorDocument 404 /404.php

它工作正常,但它需要所有 .jpg、.js、.css 等...
我希望它只接受 .php 并对所有其他人执行正常的 404 错误。

我在任何地方都找不到该选项。

非常感谢。

最佳答案

不确定,但试一试:

<Files ~ "\.php$">
    ErrorDocument 404 /404.php
</Files>

引自 Files Directive文档:

The <Files> directive limits the scope of the enclosed directives by filename.

关于php - 自定义 404 错误页面——仅适用于 PHP 页面,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9631496/

相关文章:

php - 使用 PHP 到 MySQL 的多次插入不适合我,但适合其他人

php - 合并 2 个 MySQL 数据库

php - mysql 三个表的内连接和外连接

apache - htaccess 中的 url 参数问题

.htaccess 301 http ://redirect to https://not being indexed by Google

php - 如何知道 .pem 文件是否正确

django - 为 Django 创建开发环境

php - 带有 PHP 的 Docker Apache - 地址不可用:AH00056:连接到 [::]:80 上的监听器

php - Ubuntu 上的 LAMP 创建写保护文件

apache - 符号链接(symbolic link)到/project/current/web work 但不是/project/current/web/app.php (Apache/Ubuntu/Symfony2)