从403 ErrorDocument 403错误

我在我的Apache 2.4.7安装中有以下configuration脚本:

<Directory "/www"> Options Indexes FollowSymLinks AllowOverride All <RequireAll> Require all granted Require not ip ip.range.A ip.range.B </RequireAll> RewriteEngine On RewriteRule ^faq/(\w+)/(\d+)/?$ faq.php?code=$1&num=$2 [NC] ErrorDocument 403 /www/faq.php?code=web&num=403 </Directory> 

而且,当我尝试使用其中一个阻止的IP地址查看页面时,我收到此错误:

此外,尝试使用ErrorDocument处理请求时遇到403禁止错误。

因为我想为来客提供两种403服务; 我必须redirectIP范围AB限制的用户才能显示faq/WEB/403/页面。

有没有办法阻止用户使用这些IP的访问,并显示他们我的自定义ErrorDocument页面?

我尝试使用以下代替requireAll标记( 在RewriteCond指令中定义):

 RewriteCond %{REMOTE_HOST} ^ip.range.A [OR] RewriteCond %{REMOTE_HOST} ^ip.range.B RewriteRule /faq/WEB/403/ [L,R] 

但无济于事。 用户可以在后一种情况下自由访问页面。

当前configuration文件如下(并且没有用户被阻止访问网页):

 <Directory "/www"> Options Indexes FollowSymLinks AllowOverride All RewriteEngine On RewriteRule ^faq/(\w+)/(\d+)/?$ faq.php?code=$1&num=$2 [NC] RewriteCond %{REMOTE_HOST} ^ip.range.A [OR] RewriteCond %{REMOTE_HOST} ^ip.range.B RewriteRule /faq/WEB/403/ [L,R] </Directory> 

对于这个错误:

此外,尝试使用ErrorDocument处理请求时遇到403禁止错误。

你正在保护/ www目录。 由于403文件也在这个目录中,因此对用户的访问是不被允许的。 你需要把你的403页面放在它自己的不属于/ www的目录中。

根据源IP有两个分离页面,我不确定你只能用apacheconfiguration。 ErrorDocument是中断正常apachestream程的“特殊”命令。 更好的方法是使用PHP或任何服务器端语言来完成此操作。