Support

Admin Tools

#43368 Possible recursive 403 handling with .htaccess Maker and custom ErrorDocument

Posted in ‘Admin Tools for Joomla!’
This is a public ticket

Everybody will be able to see its contents. Do not include usernames, passwords or any other sensitive information.

Environment Information

Joomla! version
6.1.x
PHP version
8.3
Admin Tools version
7.9.3

Latest post by nicholas on Sunday, 27 September 2026 12:43 CDT

fw611
Can't get any Text Format to work, sorry! I am using Joomla with Admin Tools 7.9.3 and an Apache/ISPConfig hosting environment. I have encountered a reproducible issue with the "Common hacking tools and bandwidth hoggers" / User-Agent blocking rules generated by the .htaccess Maker. ISPConfig configures custom Apache error documents for the website, including: Alias /error/ "/var/www/example.com/web/error/" ErrorDocument 403 /error/403.html ErrorDocument 404 /error/404.html ErrorDocument 500 /error/500.html Admin Tools generates User-Agent blocking rules similar to: RewriteCond %{HTTP_USER_AGENT} Ahrefs [NC,OR] RewriteCond %{HTTP_USER_AGENT} curl [NC,OR] RewriteCond %{HTTP_USER_AGENT} Go-http-client [NC,OR] ... RewriteCond %{HTTP_USER_AGENT} wp2shell [NC] RewriteRule ^ - [F,L] Requests using one of these blocked User-Agents can result in HTTP 500 instead of HTTP 403. Apache logs: AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. The issue is reproducible, for example: GET / HTTP/1.1 User-Agent: AhrefsBot/7.0 → HTTP 500 GET /error/403.html HTTP/1.1 User-Agent: AhrefsBot/7.0 → HTTP 500 The same behaviour occurs with several User-Agents blocked by the generated rules, including: curl/8.6.0 AhrefsBot/7.0 Go-http-client/1.1 PetalBot Bytespider python-requests/2.32.3 Apache subsequently logs AH00124. My assumption is that the following happens: blocked User-Agent → RewriteRule [F,L] → HTTP 403 → Apache ErrorDocument /error/403.html → internal request for /error/403.html → same User-Agent is blocked again → HTTP 403 → ErrorDocument /error/403.html → ... → AH00124 / HTTP 500 I therefore tried to exclude the ISPConfig error pages using: RewriteRule ^error/ - [L] I entered this under: Custom .htaccess rules at the top of the file However, in the generated .htaccess this rule is placed after the "Common hacking tools and bandwidth hoggers" User-Agent block. The resulting order is essentially: RewriteEngine On # PHP Authorization rule ##### Common hacking tools and bandwidth hoggers block -- BEGIN ... RewriteRule ^ - [F,L] ##### Common hacking tools and bandwidth hoggers block -- END RewriteBase / # HTTPS redirect ##### Custom Rules (Top of File) -- BEGIN RewriteRule ^error/ - [L] ##### Custom Rules (Top of File) -- END Consequently, the /error/ exclusion cannot prevent the recursion because the blocked User-Agent has already matched the earlier [F,L] rule. Could you please clarify: 1. Is this interaction between the generated User-Agent blocking rules and Apache ErrorDocument 403 known or expected? 2. What is the recommended way to exclude /error/ from the User-Agent blocking rules generated by Admin Tools? 3. Is there an Admin Tools setting intended for this situation? 4. Should "Custom .htaccess rules at the top of the file" normally be emitted before the "Common hacking tools and bandwidth hoggers" block? 5. Would you recommend disabling the User-Agent blocking feature when Apache/ISPConfig uses URI-based custom ErrorDocuments such as /error/403.html, or is there a preferable solution? I would prefer to solve this through the .htaccess Maker configuration rather than manually editing the generated .htaccess, since manual changes would be lost when the file is regenerated. The problem has been reproduced repeatedly and correlates directly with Apache AH00124 entries. Normal requests from non-blocked User-Agents are unaffected. Thank you.

fw611
One additional detail may be relevant: ISPConfig 3.3.2 changed its default behaviour regarding custom error pages. According to the ISPConfig 3.3.2 release notes, "Custom error pages are now disabled by default for newly created websites", while existing websites are not changed by the update. This website is an existing ISPConfig website and therefore still has the traditional ISPConfig configuration: Alias /error/ "/var/www/example.com/web/error/" ErrorDocument 400 /error/400.html ErrorDocument 401 /error/401.html ErrorDocument 403 /error/403.html ErrorDocument 404 /error/404.html ErrorDocument 405 /error/405.html ErrorDocument 500 /error/500.html ErrorDocument 502 /error/502.html ErrorDocument 503 /error/503.html This seems particularly relevant because the recursion I can reproduce starts when an Admin Tools User-Agent blocking rule generates a 403 response and Apache subsequently internally requests /error/403.html. ISPConfig 3.3.2 does not state in its release announcement that the changed default for custom error pages is related to this particular recursion issue, so I do not want to assume that there is a direct connection. However, I thought this change was worth mentioning.

nicholas
Akeeba Staff
Manager

You said that your hosting solution adds this to the virtual host configuration:

Alias /error/ "/var/www/example.com/web/error/"

ErrorDocument 400 /error/400.html
ErrorDocument 401 /error/401.html
ErrorDocument 403 /error/403.html
ErrorDocument 404 /error/404.html
ErrorDocument 405 /error/405.html
ErrorDocument 500 /error/500.html
ErrorDocument 502 /error/502.html
ErrorDocument 503 /error/503.html

You have not told me if the /var/www/example.com/web/error directory actually exists, if it's readable by Apache, whether it has the custom error page files, and whether they are readable.

You can PROBABLY solve this by adding error to the "Allow direct access, except .php files, to these directories" option.

Ideally, you should just add the following to "Custom .htaccess rules at the bottom of the file" to reset custom error pages since it does not seem you are serving concrete custom error pages anyway:

ErrorDocument 400 default
ErrorDocument 401 default
ErrorDocument 403 default
ErrorDocument 404 default
ErrorDocument 405 default
ErrorDocument 500 default
ErrorDocument 502 default
ErrorDocument 503 default

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

fw611
Thank you. I tested your first suggestion. The /var/www/example.com/web/error directory does exist and contains the ISPConfig error documents 400.html, 401.html, 403.html, 404.html, 405.html, 500.html, 502.html and 503.html. The files exist and are readable. I added "error" to "Allow direct access, except .php files, to these directories" and regenerated the .htaccess file. Admin Tools correctly generated the corresponding rules: RewriteCond %{REQUEST_FILENAME} !(.php)$ RewriteCond %{REQUEST_FILENAME} -f RewriteRule ^error/ - [L] However, this rule is generated later in the .htaccess file than the "Common hacking tools and bandwidth hoggers" User-Agent blocking rules. Therefore, the problem remains reproducible. After regenerating the .htaccess file, I tested these two requests: GET / with User-Agent: AhrefsBot/7.0 GET /error/403.html with User-Agent: AhrefsBot/7.0 Both requests still result in Apache logging: AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. The corresponding Apache log entries were generated at 16:53:57 immediately after the two test requests. This seems to confirm that the direct-access exception for /error/ cannot prevent this particular recursion because the User-Agent blocking rule with [F,L] is evaluated before the generated direct-access exception. There are also additional AH00124 entries caused by real external requests, so the behaviour is not limited to my controlled tests. I will now test your second suggestion using "ErrorDocument ... default" in "Custom .htaccess rules at the bottom of the file" and report the result. Your second suggestion using “ErrorDocument ... default” in “Custom .htaccess rules at the bottom of the file” solved the issue. The previously failing requests now correctly return HTTP 403 instead of HTTP 500, and no new AH00124 entries are generated. I also verified that the existing protection rules still work as expected: a request for /.env returns HTTP 404, while a normal request to / returns HTTP 200. So this solution works correctly in my ISPConfig setup. Thank you for your help.

nicholas
Akeeba Staff
Manager

The redirect flags are not important in this case. Grab a cold drink, this is convoluted. Having an Alias for the error pages complicates things. The documentation says this:

First, all Redirects are processed before Aliases are processed, and therefore a request that matches a Redirect or RedirectMatch will never have Aliases applied. Second, the Aliases and Redirects are processed in the order they appear in the configuration files, with the first match taking precedence.

Since the protection is a set of redirect rules you'd have to set your Alias rules again in the bottom of the file for them to apply. You cannot have the server protection (redirect rules) in .htaccess and fall back to the Alias rules from your VirtualHost. I get what they are doing and why they are doing it. There is no good way to do it when you can override the Apache server configuration in so many ways: default config, virtual hosts, directory rules, cascading .htaccess, and I am pretty sure I forgot something...

That said, I've found that most people don't actually use custom error pages and when they do they are materially worse than the built-in ones. This sounds odd, but – depending on the browser – if the server response body for an HTTP status other than 200 is less than around 200 bytes the browser shows its own error page which is more user-friendly as it has browser-specific information on what the user can do next. Moreover, having custom error pages for 404 and 403 errors may replace Joomla's built-in error pages which is a lot more confusing.

And that's why I suggested using the ErrorDocument ... default lines. Falling back to the default Apache error pages allows the browser to display its own error page when appropriate, and allows Joomla to handle its 403, 404, and 500 errors with site-specific content.

Nicholas K. Dionysopoulos

Lead Developer and Director

🇬🇷Greek: native 🇬🇧English: excellent 🇫🇷French: basic • 🕐 My time zone is Europe / Athens
Please keep in mind my timezone and cultural differences when reading my replies. Thank you!

Support Information

Working hours: We are open Monday to Friday, 9am to 7pm Cyprus timezone (EET / EEST). Support is provided by the same developers writing the software, all of which live in Europe. You can still file tickets outside of our working hours, but we cannot respond to them until we're back at the office.

Support policy: We would like to kindly inform you that when using our support you have already agreed to the Support Policy which is part of our Terms of Service. Thank you for your understanding and for helping us help you!