Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex Apache错误404和文件匹配_Regex_Apache_Http Status Code 404 - Fatal编程技术网

Regex Apache错误404和文件匹配

Regex Apache错误404和文件匹配,regex,apache,http-status-code-404,Regex,Apache,Http Status Code 404,我们的服务器配置如下: ErrorDocument 404 http://www.domain.com/somepage <FilesMatch "\.(gif|jpe?g|png|s?html|css|js)$"> ErrorDocument 404 default </FilesMatch> errordocument404http://www.domain.com/somepage 错误文档404默认值 所有“未找到”页面都重定向到/somepage。若有

我们的服务器配置如下:

ErrorDocument 404 http://www.domain.com/somepage
<FilesMatch "\.(gif|jpe?g|png|s?html|css|js)$">
   ErrorDocument 404 default
</FilesMatch>
errordocument404http://www.domain.com/somepage
错误文档404默认值
所有“未找到”页面都重定向到/somepage。若有“未找到”的图像或css或js请求,我们将请求重定向到标准404页面。如果存在的目录中缺少映像(例如

如果请求的文件是 并且存在/document_root/images/aaa/那么就没有问题了,一切都按预期进行。aaa/dir不存在时出现问题。。然后
FilesMatch“\(gif | jpe?g | png | s | html | css | js)$”
不起作用(不匹配),请求被发送到

有没有办法匹配不存在目录中不存在的文件(gif、jpg、css…)


谢谢

我通过添加以下内容解决了这个问题

 <LocationMatch ".+\.(jpg|png|gif)$">
     ErrorDocument 404 /images/404Image.png
 </LocationMatch>

ErrorDocument 404/images/404Image.png
将扩展添加到location match正则表达式也适用于您