I am running a LAMP Server on Linux. In apache2.conf we have:
<Directory />
Options FollowSymLinks
AllowOverride None
Require all granted
<LimitExcept GET POST HEAD>
deny from all
</LimitExcept>
ErrorDocument 403 /var/www/html/error.html
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REMOTE_ADDR} !127.0.0.1
RewriteRule .* - [F]
</Directory>
<Directory /var/www/>
Options FollowSymLinks
AllowOverride None
Require all granted
<LimitExcept GET POST HEAD>
deny from all
</LimitExcept>
ErrorDocument 403 /var/www/html/error.html
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REMOTE_ADDR} !127.0.0.1
RewriteRule .* - [F]
RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR]
RewriteCond %{HTTP_USER_AGENT} python-requests/2.18.4 [NC,OR]
RewriteCond %{HTTP_USER_AGENT} curl/7.47.0 [NC]
RewriteRule .* - [F,L]
</Directory>
<Directory /var/www/html>
Options FollowSymLinks
AllowOverride None
Require all granted
<LimitExcept GET POST HEAD>
deny from all
</LimitExcept>
ErrorDocument 403 /var/www/html/error.html
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REMOTE_ADDR} !127.0.0.1
RewriteRule .* - [F]
RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR]
RewriteCond %{HTTP_USER_AGENT} python-requests/2.18.4 [NC,OR]
RewriteCond %{HTTP_USER_AGENT} curl/7.47.0 [NC]
RewriteRule .* - [F,L]
</Directory>
<Directory /var/www/html/wiki>
Options FollowSymLinks
AllowOverride All
Require all granted
<LimitExcept GET POST HEAD>
deny from all
</LimitExcept>
ErrorDocument 403 /var/www/html/error.html
RewriteEngine On
RewriteCond %{REQUEST_METHOD} POST
RewriteCond %{REMOTE_ADDR} !127.0.0.1
RewriteRule .* - [F]
RewriteCond %{HTTP_USER_AGENT} ^-?$ [OR]
RewriteCond %{HTTP_USER_AGENT} python-requests/2.18.4 [NC,OR]
RewriteCond %{HTTP_USER_AGENT} curl/7.47.0 [NC]
RewriteRule .* - [F,L]
</Directory>
Note the ErrorDocument command is identical in each and every directory block specified in apache2.conf including In the .htaccess file in that directory and in the .htaccess files in all of the sub directories under it (which are carbon copies of the same .htaccess file), we have, in relevant part:
<IfModule mod_authz_core.c>
Require all denied
ErrorDocument 403 /var/www/html/error.html
</IfModule>
<IfModule !mod_authz_core.c>
Order allow,deny
Deny from all
ErrorDocument 403 /var/www/html/error.html
</IfModule>
ErrorDocument 403 /var/www/html/error.html
The problem is that on testing, we get a 403 as expected, BUT the page displayed is the generic 403 page plus a line displaying "Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request."
My understanding is that "Deny from all" should give the 403 redirect to the designated ErrorDocument given that the following is also in every directory block in apache2.conf:
ErrorDocument 403 /var/www/html/error.html
So why is error.html getting an additional duplicative 403 redirect? This doesn't seem to make sense.