Implementing a Redirect on the 404 error page
I need some assistance figuring out if the following is possible:
As 301/302/etc. redirects are STILL NOT ALLOWED from the server-side on Wild Apricot sites (years after being requested in wishlist forums), I wrote a custom javascript snippet that triggers on the /Sys/Error/404 page when trying to access an old/removed page or URL.
The javascript, however, needs access to what would be the normal document.referrer variable for the MISSING page URL which would allow me to check against and redirect to another page, but as the server process for the 404 error seems to skip over loading the missing page URL entirely the normal document.referrer URL ends up being the external site page (i.e., google) or the internal site page with a clicked link to the missing page which would be incorrect to use to determine what page to redirect to in my situation.
I could hypothetically store a cookie for inner site traffic for clicked links I guess but there would be no way to handle the scenario for external traffic, as coming from google for instance would immediately trigger the 404, skipping over the missing page url, and any chance of setting a cookie for the missing URL.
This being the case, I checked for but could not find a related variable printed in the source code or in the browser cookies/local storage/session data that was related to this missing page URL that causes the 404 error and came up empty.
So, at this point, I'm wondering if there is in fact a related javascript document.referrer variable for the missing page URL that causes the 404 process to happen, which would need to be accessible on the 404 page?
Maybe a global "bonaPage" variable that isn't currently shown in the source code but is still available to use if known to exist?
If not, it would be great if it got added to the /Sys/Error/404 url as a query param value (i.e., /Sys/Error/404?referral=missing-page-path) or even better (much cleaner and you don't have to worry about encoding it in the server code) if it was included in the source code with the rest of the "bonaPage" javascript variables added to the <head> section in the <script> snippet with the ID "idJavaScriptEnvironment".
i.e., something like: const bonaPage_404referral = "/missing-page-path"
Otherwise, I'm at another loss here for what can be done.
Thanks for your time and consideration on the matter.