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?

the-wabbit
  • 40,319
  • 13
  • 105
  • 169
NotGaeL
  • 277
  • 1
  • 3
  • 13

2 Answers2

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

powo
  • 356
  • 2
  • 6
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

powo
  • 356
  • 2
  • 6
  • 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