【发布时间】:2014-07-30 15:19:06
【问题描述】:
以下代码适用于错误代码 404,但对于 403 代码不起作用。它不显示页面 403.html 并继续在状态中显示代码 403 而不是 200 OK。为什么?
Deny from adsl.eunet.rs
RewriteEngine On
RewriteBase /
RewriteRule ^403\.html/?$ - [L]
# If the requested file doesnt exist
# and if the requested file is not an existing directory
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . 403.html [L]
【问题讨论】:
-
对非文件或目录的请求执行最后一次重写。这与 404 处理相同。我可以知道您的代码是如何生成 403 的吗?
-
拒绝来自 adsl.eunet.rs
-
好的,如果您使用的是
Deny from,那么您必须使用ErrorDocument 403 /403.html指令。您可以在您的网站上编写 php 代码吗? -
我的虚拟主机上允许使用 PHP,但我不知道如何使用它以及做什么。
标签: apache .htaccess error-handling