1

When I force the error 400 by trying http on a https port I get a 302 found code with the https://myserver/mypage.html link I want to show, and I have to click it to get to the page

How can I skip this step and have a straight redirection to the https:// link?

2

I think it could work by defining a static ErrorDocument eg:

ErrorDocument 400 /redirect_https.txt

and create the file redirect_https.txt in your document root with the following content:

HTTP/1.1 302 Found
Location: https://myserver/mypage.html

this works (even tried) and sends the browser a "faked" HTTP-redirect

  • Nice, man! Works sweet as a charm in every browser. Thank you very much :) – NotGaeL Dec 15 '11 at 9:09
1

I assume that 400/BadRequest is a bit special in this situation, because you are simply talking a wrong protocol to the server and what you get back isn't even a valid HTTP response (try: curl -i http://myserver:443/ .. there are no headers).

see also: Problems redirecting Error 400 Bad Request to custom page

  • Well yes. What is special is only one port is open through firewall and is https so when I get a http request to that address (which can be pretty common since people can forget to use https:// and just do mypublicIP:myopenport instead of https:// mypublicIP:myopenport) I would like to offer the posibility to seamlessly switch to https. – NotGaeL Dec 14 '11 at 22:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.