Please note, this is a STATIC archive of website technosmarter.com from 20 Jul 2022, cach3.com does not collect or store any user information, there is no "phishing" involved.
 

Redirect http to https using .htaccess file : step wise process


SSL certificates are more important for website security. According to the search engine algorithm, if your website is not SSL certified, then your website is not considered secure.

To secure the website, you have to use SSL certificates.HTTP shows the Unsecured website and Https refers Secure website shows up. If your website has SSL certificates then your website will get redirect to HTTPS from HTTP. You have to use the .htaccess file to redirect from HTTP to HTTPS.

If chrome, Firefox, and other browsers warn you that your website is not secure then you will need to get SSL certified. Apply SSL certificates to your website for free. Without SSL, your website will show insecure to the visitors. According to SEO Techniques, If Your Website has no SSL certificates, your website content is not considered as secure. Google or other search engines also prefer to be more interested in the same website which is SSL certified.

If you want to secure your website, The certificate will need to be applied to the domain of your website. It gets very important to redirect from HTTP to HTTPS.

If you want to redirect your website to Http to https, you need to create a .htaccess file. You have to edit the codes in the .htaccess file. Before we move onto redirecting HTTP to HTTPS, here’s how you can edit .htaccess file. Here, we will explain about .htaccess file.

Create a .htaccess file for redirection-

The .haccess file is one of the files that use to do many different tasks on the server. You can edit the .haccess file according to your need.

1.redirect http to https .

2.redirect https to http.

3. redirect non www to www.

4. redirect http to www.

5. redirect https to www.

You can define like this - 1.Non-https to https.

2.Non-http to http.

3.Non-www to www.

Edit .haccess file

You can edit the .htaccess file in two ways. 1. Edit .haccess file on the local computer and upload on the global server

Steps to edit .haccess file.

I. First of all open your system notepad(notepad++, sublime etc).

II. Open new file.

III. Create a file and save with name .htacess

IV. Upload this .htacess file on your website root folder.

2. You can edit .haccess file. file through cpanel.

Steps to Steps to edit .haccess file through cpanel.

I. Log in to your server c panel .

II. Click on file manager.

III. Come to the website root folder

. IV. Create a new file.

V. Save with name ".htaccces" only.

Redirect HTTP to HTTPS

Let's move on the next step, redirect HTTP to https. It is a very essential part of SEO for transferring your traffic on the secure connection.

1. Redirect All Web Traffic

Redirect HTTP to HTTPS automatically-

If you have already created a .htacces file on your server, then add this code in .htacces file. According to Godaddy Redirect HTTP to HTTPS automatically and StackOverflow http to https redirecting.


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

The above example will help you redirect all web traffic to https secure connection. Add this code in your .htaccess file. You do not need to add more code to redirecting.

Example 2-

You can follow this code. Add this code in your existing .htaccess file.



RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

2. Redirect Only a Specific Domain

You can redirect a specific domain . For redirecting a specific domain to use HTTPS, add the following:


RewriteEngine On 
RewriteCond %{HTTP_HOST} ^example.com [NC]
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

3.Redirect Only a Specific Folder

There is another example for a specific folder redirecting. You can redirect HTTPS on a specific folder, add the following:


RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteCond %{REQUEST_URI} folder 
RewriteRule ^(.*)$ https://www.example.com/folder/$1 [R,L]

In this way, you can redirect your website traffic to a secure connection. The chrome and firefox browser will never warn you.


Please Share

Recommended Posts:-