Custom Error Page: using script path


I have a setup, where through rewrite rules on "/" context level I direct [almost] everything to index.php file, where I process the "route" in URL, that is "/fftracker/search/" for example will be processed by the main PHP script and content will be shown based on the logic designed specifically for "fftracker" and "search" nodes.
I have a route for HTTP error pages as well, looking like "/httperror/404/" as example, and I want custom error pages load those. But right now, when I setup 404 (again, as exmaple) error page to "/httperror/404" it looks like server is opening index.php without the original URL provided to it in any way, thus it displays a different page, not the one that is supposed to be shown as 404. As a visual example: should look like, but in fact looks like a 400 error page (as per index.php's logic). I'm using IP for the link, since I am in process of moving from a Windows VPS with Apache to Linux with OLS, so domain has not been linked to IP yet.
How can I make it so proper error page is displayed? Maybe there is some $_SERVER variable, that OLS passes in case of such errors, that I can leverage? Or maybe I need to adjust something in server setup?

Thank you.
"/httperror/404" is not a physical page, it's a page generated by "index.php", if the URL of the actual page is "/httperror/404" or if a 404-like error is triggered internally in the script.
Custom error pages are already setup like shown below:
1663057144587.png With current setup, if I remove the custom page setup for 404, and go to - I will get OLS 404 page. If I re-add the setup, I will be getting the 400 error page, because "index.php" will be getting URL of ".well-known/security6.txt", where ".well-known" is not a supported route. On the other hand, if instead of "/httperror/404/" I use "" in the setup - it gets redirected, and 404 error is shown. But I do not want redirect.

If I am understanding correctly, how things work, if I am using "/httperror/404/", OLS essentially works as a rewrite rule, when it does not change the URL and simply "directs" the call to appropriate file (in my case index.php, since everything is being directed there). The easiest way I see to achieve what I want is to somehow learn on PHP level, that OLS is directing a request to the script because of an error. Like check something like $_SERVER['OLS_ERROR_CODE'] or something. Does OLS have something like that?

It looks like there is $_SERVER['REDIRECT_URL'], which is kind of explained in Apache manual. Does OLS have the same logic for this variable? Are there any possible "limitations" in terms of using it as a "flag" that an internal OLS redirect was done?
Last edited: