Apache2 Rewrite http to https on port 5553

I want to know if it is possible via htaccess to rewrite my URL http://mysite.com:5553 to https://mysite.com:5553.

My Apache server has only one virtualhost on port 5553, with SSL on.


Solution 1:

Running http and https on the same port won't work. Although the client will know whether it's speaking SSL or not, Apache will expect one or the other and will not detect which one is being spoken by the client.

This will result in HTTP 400 response codes in response to whichever one Apache was not expecting.

If you put them on different ports and use a separate vhost for the SSL and non-SSL requests, it certainly is possible to respond to http requests with a redirect response telling the client to make a new https request. It will not be possible to rewrite an http request into an https request.