htaccess的和定制的ErrorDocument不同文件类型

编程入门 行业动态 更新时间:2024-10-24 20:18:29
本文介绍了htaccess的和定制的ErrorDocument不同文件类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我不知道是否有可能使用mod-rewrite随着减速的ErrorDocument根据请求文件的类型定制的错误页面。

I'm wondering if it's possible to use mod rewrite along with the ErrorDocument deceleration to customize the error pages depending on what type of file is requested.

例如不存在的HTML或PHP文件请求Apache将给予很好的自定义的HTML页面。

For example a non-existent html or php file is requested Apache will give nice custom HTML page.

但是,如果不存在的图像,JS,CSS等...文件请求然后Apache将发球出一个基本的HTML文件与在其上仅一个链接。

But if a non-existent image, js, css, etc... file is requested then Apache will serve out a basic html file with only a link on it.

这种行为的一个很好的例子就是Facebook的。尝试请求伪造的JavaScript文件,您将收到一个不同的页面,然后如果你请求一个不存在的php文件。

A good example of this behavior is Facebook. Try requesting a bogus JavaScript file, you will receive a different page then if you were to request a non-existent php file.

推荐答案

最后同时使用的ErrorDocument和规则集这工作,因为PHP页面抛出一​​个404未找​​到适合我的组合。

Ended up using a combination of both ErrorDocument and RewriteRules this works because the php page throws a 404 Not Found for me.

RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule .*(?<!.js|.css|.ico|.txt|.bmp|.gif|.png|.jpeg|.jpg)$ /error/404.php [L] ErrorDocument 404 /404_basic.html

更多推荐

htaccess的和定制的ErrorDocument不同文件类型

本文发布于:2023-11-01 23:22:06,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1550703.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:文件类型   htaccess   ErrorDocument

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!