Firstly: A simply Port 80 -> Port 443 Rewrite WILL NOT fix this. In almost every previous question, mail thread, forum thread, etc., I have found this was the first ignorant response and was parroted several times.
Secondly: Yes I know you cannot serve HTTP and HTTPS traffic on the same port. This is not that.
Apache Server hosting multiple sites via port multiplication. Port 80 serves a public site. Port 443 serves the secure version of that site.
Ports 7443, 8443, and 9443 each serve separate SSL-Secured sites.
If a user mistypes the URL, or is given a link that isn't valid, say http://hostname.tld:7443, they are given the following ridiculous page:
Instead of the server just redirecting them over to https://hostname.tld:7443.
My Question is, how in the name of Zeus's butthole can you modify Apache's behavior or this error message to redirect the user automagically?
Apache is obviously serving a non-https request (to display that error message) even though it is configured for HTTPS. It seems remarkably dumb to me to not just do the redirect by default, but I can understand why they went with the behavior they did, even if I don't agree with it. So my question is: can you change it? They are handling the error SOMEWHERE, and with Apache being the configuration cornucopia that it is, it stands to reason there is some directive somewhere to handle this behavior, but I have been unable to find it in several hours of tinkering so far.
I have attempted a variety of things including:
ErrorDocument 400directives to get to a CGI and a PHP script that just send
Locationheaders. This results in a blank page. Using
ErrorDocument 400 https://hostname.tld:7443simply results in that link being displayed on the page.
Using almost every combination of
mod_rewriteI or Google can come up with, including blanket statements that direct the site entirely; these never work. Literally, they do nothing. I'm surmising that Apache is kicking to the above error before even attempting to process the rewrite directives.
I can't use port-based redirects, because of the custom port use. I can't use script-based redirects because they never get served because of the http/https mismatch. I'm almost willing to chalk this up to a bug, or an unintended behavior, but somebody had the forethought to put a very custom error message in there, they didn't bother thinking that maybe you'd want to just cart to the URL they are already providing?