Custom Error Pages with proper HTML code

#1
Scenario: Need to set custom error page for a domain/virtual host, let's assume for FORBIDDEN content, with return HTML code 403 - which is vital being received & logged, as it plays into blocking such consecutive requests via modSecurity module.

The rewrite code in question which blocks requests for exe & asp extension files :

RewriteRule \.(asp|exe)$ - [F,L]​

I am aware that one can specify custom error pages in the OLS webadmin for each virtual host in the General tab, problem is; once specified a custom 403 page here it starts working as a REDIRECT (HTML code 301) instead of 403, and thus modSecurity can not catch it.
Makes no difference if the custom page is entered as an URL ( https://mydomain.com/403.html ) or as local file relative to the Doc Root ( /403.html ), they both function as redirects instead of includes/links.

The only solution I found is to delete/not specify a custom 403 error page, and thus 403 code is correctly returned & logged, but then the default OLS error page remains to be displayed. :(

What we need, respectfully request, is a way to have custom error pages work the same way default OLS error pages function, have them linked/included from within the DocRoot (better yet, the $VH_ROOT) returning the proper HTML code instead of just a 301 redirect.

BTW, until this is implemented, where exactly is the default 403 error page located in the OLS install directory? I fould the 404 page in the Examples dir, but not the other error page templates.
 
#2
Based on my testing:
  • When a request is blocked by ModSecurity, OLS returns the server’s default 403 error page.
  • When a 403 is triggered by a rewrite rule or file permission, OLS returns the custom 403 error page.

The default error page is a built-in feature, and cannot be modified.
 
#3
Same, however my issue was not with which 403 page is returned but which HTTP code is returned when specifying a custom page in the web admin - namely the (correct) 403 code when NO custom page specified and a 301 code (redirect) when you have a custom page in the web admin.

My request was so that the correct HTTP code (403 - forbidden) is returned EVEN WHEN custom pages are used instead of the redirect code (301).

(I just noticed that in my initial post I wrote "HTML code" instead of HTTP return code, which is why it might have got confusing to what I was referring towards)
 
Top