http code




HTTP 301/302


An HTTP response with this status code will additionally provide a URL in the header field "Location"

curl -I http://mydomain

HTTP/1.1 301 Moved Permanently
Date: Thu, 28 Jun 2018 03:30:23 GMT
Server: Apache
Location: https://mydomain/
Content-Type: text/html; charset=iso-8859-1

HTTP 302

The HTTP/1.0 specification (RFC 1945) initially defined this code, and gives it the description phrase "Moved Temporarily".

HTTP 301

The 301 redirect is considered a best practice for upgrading users from HTTP to HTTPS.

i.e. http -> https

RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^.*$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]