How to redirect HTTP to HTTPS
How to redirect HTTP to HTTPS
HTTPS is a protocol for secure communication over a computer network which is widely used on the Internet. More and more website owners are migrating from HTTP to HTTPS, mainly due to the 5 following reasons.
Google announced that sites using HTTPS will get a slight ranking factor in Google search. You can achieve faster performance with the new HTTP/2 protocol which requires HTTPS due to browser support. And yes, Charvi Associates supports HTTP/2 on all servers.
- HTTPS is more secure and your visitor's data is entirely encrypted.
- HTTPS can build trust by enabling the green padlock in the visitor's web browser address bar.
- If someone is visiting a website from HTTPS and going to an HTTP website, the referral data is lost in Google Analytics. It usually ends up lumped together with the "direct traffic." If someone goes from an HTTPS website to another HTTPS website, the referral data is still passed. So by migrating from HTTP to HTTPS, you can actually have more accurate referral data.
- Using the following code in your .htaccess file automatically redirects visitors to the HTTPS version of your site:
Add in .htaccess File
RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Note: If you have an existing .htaccess file: Do not duplicate RewriteEngine On.
Connectionless: HTTP is connectionless. When the HTTP client opens the browser, the browser initiates an HTTP request. After making the request, the client disconnect from the server and wait for the response. When the response is ready, the server re-establish the connection again and delivers the response to the client, after which the client disconnects the connection. So both client and server know about each other during the current request and response only.
Media Independent: HTTP is media independent. HTTP can deliver any sort of data, as long as the two computers can read it.
Stateless: The HTTP is stateless. The client and server just know about each other just during the current request. If the connection is closed, and two computers want to connect again, they need to provide information to each other anew, and the connection is handled as the very first one.