I looked through a number of similar posts, but couldn't find the answer there:
I am moving a website from a server running apache 2.2 to another server running apache 2.4 (CentOS 6 to CentOS 7).
On the old server, I am specifying an error document, redirecting the user to a different site when a certain environment variable is not true:
Works in apache 2.2:
ErrorDocument 403 https://example.com/error_message.html
Include conf/includes/include_file
<Directory /var/www/html>
...
AllowOverride None
order deny, allow
deny from all
allow from env=variable_set_though_include_file
</Directory>
ErrorDocument part does not work in apache 2.4. The rest of the functionality works as expected. Traffic is allowed when on the correct network, when the user is on the wrong network, s/he gets a 403 error:
ErrorDocument 403 https://example.com/error_message.html
Include conf/includes/include_file
<Directory /var/www/html>
...
AllowOverride None
Require all denied
<RequireAny>
Require env variable_set_through_include_file
</RequireAny>
</Directory>
The error message I am getting when the environment variable is not true, is:
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
The web-page I want to redirect to through the ErrorDocument statement is on a different server (no configuration changes there) and does not have any access restrictions.
Any clue?
RequireAny
statement with only one thing in it?Require all denied
statement. I don't think you need that statement at all, and it may be causing everything to be denied. See Upgrading from Apache 2.2 to 2.4; access control. It shows an example where denying and then allowing from a host becomes just requiring the host.