We can force SSL in apache servers with following config:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Here, we tell the apache server that return a 301 Moved Permanently
response to the client.
But there is another status 101 Switching Protocols
and I think this status code is more suitable since we are switching from plain HTTP to HTTPS.
Am I right? Anything wrong? Which status code should I use?