Zephyrnet Logo

How to Set a 301 Redirect from HTTP to HTTPS Website Version — Serpstat Blog

Date:

Why Use 301 to Redirect HTTP to HTTPS?

The HTTP protocol operates on the principle of requests and responses. This means that when a web browser sends out a request, the server responds accordingly, completing the communication.

An HTTP redirect forwards a site or a page to a different URL address permanently or temporarily. If you want to move a website to a different address forever, SEO experts advise implementing it through the 301 status code.

Let’s see why that’s the ultimate choice.

SEO Advantages of 301 Redirects for HTTP to HTTPS Migration

It might seem overwhelming to relocate an entire website from HTTP to HTTPS. However, when executed professionally, the migration can enhance a website’s performance in search. 301 redirects indicate a cleaner and more straightforward migration process for Google.

Which One is Better: 301 vs. 302 Redirect?

If you’re doing user tests or site maintenance with no intention of a lifetime website move, you can use the temporary 302 redirect code. Since Google recognizes that the URL move is temporary, it doesn’t pass link equity to the new page. The main page also remains indexed. 

However, there’s a catch with the 302 redirect that complicates things. Sometimes, Google thinks you mistakenly used 302 instead of 301. It starts treating the temporary redirect as a permanent 301, indexes the short-term page, and passes the link power to it. So you never know what to expect from Google will the 302 code. At some point, it starts perceiving it as 301 and no one knows when that happens—it could take months, weeks, days, or immediately.

The 301 redirect from HTTP to HTTPS is the most commonly used method as it is the most accurate and comprehensive for search engines. It ensures a smooth permanent link juice and traffic transfer. If you use other types of redirect codes, Google may get confused and take charge of your redirect at its own discretion. 301 is a sure thing.

SEO statistics report that Google is the number one search engine, owning over 85% of the market share. So keep that in mind when choosing a redirect method. We all want to be on good terms with the search giant.

Steps to Migrate a Site From HTTP to HTTPS

Migration to an encrypted and secure protocol version is a process that requires professional knowledge of coding and SEO. Hiring a web development team with experience in this area can greatly assist with the migration process. Here’s how to do it:

Installing an SSL

A Secure Sockets Layer (SSL) certificate verifies the site’s identity and protects the data exchange between a web browser and a server. The information sent is encrypted, thus ensuring safety and security.

SSL certificates serve as a safeguard, preventing interception of transmitted data during transactions. This ensures the security and privacy of sensitive information. Secure webpages have the padlock symbol in front of the URL.

SSL certificates are bought from vendors and installed by tech specialists. 

Creating 301 redirects to new HTTPS URLs

This is the most important step in the entire redirection process, so be thorough. If your redirects aren’t done correctly, SEO rankings will drop significantly.

One possible negative consequence of incorrect 301 redirects is the deindexation of the old HTTP website without Google being aware it’s connected to the newly indexed HTTPS version. The latter is perceived as a new website with no previous rankings. In addition, users who follow an old link may not be redirected to the new page.

Typically, 301s are implemented via the server or with a plugin. For the Apache Web Server redirect setup, you must execute a command through the .htaccess file. If you have a WordPress website, you can simply redirect with a plugin. We’ll get into more details about that in a bit.

Updating internal links

Even though your main URL switched to HTTPS, you still need to go over all internal links and fix them. This applies to all static content.

Let’s look at some possible link updates:

You might notice that in the browser you get an exclamation mark or a red padlock before the URL. That is a mixed content error warning you that some of your pages are loading through HTTPS and others through HTTP. Keep in mind that Google shows mixed pages as insecure, so you need to fix them. Moreover, it has a limited crawl budget and doesn’t have the resource to go over different page variations. So fixing such errors will save your budget for content that matters.

Static links in pages may cause mixed content issues. For example, a blog post links internally to another page of your website with an absolute URL (http://www.mywebsite.com/blog/) rather than a relative one (/blog).

Relative URLs point to a specific file path, while absolute ones show the complete address. The former change automatically when transitioning to HTTPS. The latter must be updated manually; there’s no other way.

CSS files also may contain static resources that load through HTTP. To find them in the page source code, simply click the right mouse button and then Inspect (or CTRL + Shift + I). From there, go to the Network menu and hit F5 to load all resources. In the Initiator column, look for the files causing the HTTP load error. Edit these files from the server and switch all HTTP to HTTPS. 

Other page elements that require special attention when redirecting a website are canonical tags. If they are still pointing to the HTTP protocol and your website is on the HTTPS one, Google will get confused and index the HTTP. On the other hand, you already did a 301 HTTP redirect to HTTPS, and Google gets stuck in a loop.

Check the canonical tags on the new HTTPS site by pressing the right button and View page source (or Ctrl + U), and then search for the word “canonical”.

Hreflang tags should also point to the correct corresponding HTTPS page. You can find them with View page source and the word “hreflang”.

Adding the HTTPS website to Google Search Console (GSC) and Google Analytics (GA4)

Once you’ve done the redirects, set up the HTTPS website in Google Search Console. From the left side menu, choose “Add property.” Pick the URL prefix option and enter the corresponding HTTPS address.

Update Google Analytics so that it tracks the HTTPS URL from now on. Go to the GA4 property you want to change. Select Admin > Data Streams > Add Stream > Web. In the Website URL field, pick https:// from the drop-down menu and enter the other part of your URL. Name the stream and hit Create stream.

Resubmitting Sitemaps

You have to resubmit the new HTTPS sitemaps to the Google Search Console property we’ve just added. Choose Sitemaps from the left menu and submit the new ones by entering each URL in the field.

Updating your Disavow File

Often this step is forgotten, but disavowing files on the new HTTPS website is another must, especially if you’ve experienced negative SEO link attacks before. The disavow file is downloaded from the HTTP version and resubmitted on the HTTPS.

Redirecting to HTTPS in Different Platforms

There are a few methods to execute HTTPS redirects depending on the platform. We’ll describe the most popular ones below.

HTTP to HTTPS Redirect in WordPress

The simplest method for a 301 redirect from HTTP to HTTPS is through a WordPress plugin. Some good ones are:

  • WP Force SSL
  • CM HTTPS Pro 
  • Easy HTTPS Redirection
  • WP Force SSL
  • SSL Insecure Content Fixer
  • Really Simple SSL

They must stay activated after installation; otherwise, you may encounter performance errors.

WordPress HTTPS redirect plugins work on the same principle—they check the SSL certificate, instruct your WordPress website to use the secure protocol in URLs, and implement the redirect changes for you. They also look for HTTP URLs that didn’t change and fix them.

301 Redirecting to HTTPS in Apache Web Server

There are two ways to redirect with 301 at the server level:

1.Redirect HTTP to HTTPS with .htaccess

The mod_rewrite module is where the .htaccess 301 redirect is implmented. In the root .htaccess file, this code must be applied:

Redirect HTTP to HTTPS with .htaccess

You need to change the URL part with your website’s name and you’re good to go. With the .htaccess method, the changes take effect automatically.

2.Redirecting with Apache Virtual Host

Use the following command to redirect from the Apache Virtual Host:

Redirecting with Apache Virtual Host

Replace the website with yours and restart the server to successfully apply the changes.

Redirect HTTP to HTTPS in Nginx

When aiming to perform a 301 redirect for all your sites to their HTTPS versions, modify the Nginx configuration file using this code sequence:

 HTTP to HTTPS in Nginx

For a specific site redirect, the Nginx command is as follows:

 HTTP to HTTPS in Nginx

You must restart the Nginx to see the result of your changes.

Note! Server changes should always be done by coding experts.

spot_img

Latest Intelligence

spot_img