JIYIK CN >

Current Location:Home > Learning > NETWORK >

How to redirect a website from HTTP to HTTPS

Author:JIYIK Last Updated:2025/03/16 Views:

HTTPS is a protocol for secure communication over computer networks and is widely used on the Internet. More and more website owners are migrating from HTTP to HTTPS, mainly due to the following 5 reasons:

  1. Google announced that websites using HTTPS will receive a slight ranking priority in Google searches.
  2. Thanks to browser support, we can achieve faster performance using the new HTTP/2 protocol, which requires HTTPS.
  3. HTTPS is more secure and your visitor's data is fully encrypted.
  4. HTTPS establishes trust by enabling the green lock icon in the address bar of your visitor's web browser.
  5. If someone visits the site from HTTPS and goes to the HTTP site, the referral data will be lost in Google Analytics. It often ends up being lumped in with “direct traffic.” If someone goes from one HTTPS site to another HTTPS site, the referral data is still passed on. So by migrating from HTTP to HTTPS, we can actually get more accurate referral data.

How to redirect HTTP to HTTPS

Having said so much, how to redirect HTTP to HTTPS? There are three specific methods:

  • Redirect HTTP to HTTPS in Nginx
  • Redirect HTTP to HTTPS in Apache
  • Redirect HTTP to HTTPS using Really Simple SSL plugin

Note: Our examples all include 301 redirect instructions, which is the correct way to implement it in terms of SEO. Using different types of redirects may have different effects on your site’s rankings.

Redirect HTTP to HTTPS in Nginx

According to W3Techs, Nginx is the fastest growing web server, with over 30% market share as of 2017. On average, one in the top 10 million websites starts using Nginx every minute.

nginx diagram

If your web server is running Nginx, you can easily redirect all HTTP traffic to HTTPS by adding the following code to your Nginx configuration file. This is the recommended way to redirect websites running on Nginx.

server {
    listen 80;
    server_name jiyik.com www.jiyik.com;
    return 301 https://jiyik.com$request_uri;
}

Jiyike uses this method to redirect HTTP to HTTPS

Redirect HTTP to HTTPS in Apache

Apache Diagram

If your web server is running Apache, you can .htaccesseasily redirect all HTTP traffic to HTTPS by adding the following code to your ./configure/redirect/file. This is the recommended way to redirect websites running on Apache.

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

Redirect HTTP to HTTPS using Really Simple SSL plugin

The third option we have to redirect from HTTP to HTTPS if the website is developed using WordPress is to use the free Really Simple SSL plugin for WordPress .

We do not recommend this method as a permanent solution, as 3rd party plugins always introduce another layer of issues and compatibility problems. Also, for HTTPS migrations, we should update the HTTP URLs in the database instead of relying on plugins. But this can be a good temporary solution.

really-simple-ssl-plugin

The plugin has over 200,000 active installations and is maintained by developer Rogier Lankhorst. We can download Really Simple SSL from the WordPress repository or search for it under “Add New” plugins in the WordPress dashboard. Here is a list of the plugin’s features:

  • All incoming HTTPS requests are redirected from HTTP to HTTPS. Use .htaccess if possible, otherwise use JavaScript.
  • The WordPress site URL and homepage URL are changed to HTTPS.
  • Insecure content was fixed by replacing all HTTP:// URLs with HTTPS://, except for links pointing to other external domains. Everything was done dynamically. No other database changes were made except for the WordPress site URL and homepage URL.

There are really no steps to using this plugin, just install it and click “Continue, Activate SSL” and you’re done.

For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.

Article URL:

Related Articles

How to Fix the “SSL Handshake Failed” Error (5 Methods)

Publish Date:2025/03/16 Views:96 Category:NETWORK

Installing a Secure Sockets Layer (SSL) certificate on your WordPress site enables it to use HTTPS for a secure connection. Unfortunately, there are a lot of things that can go wrong in the process of verifying a valid SSL certificate and e

Detailed introduction to Let's Encrypt

Publish Date:2025/03/16 Views:129 Category:NETWORK

Let's Encrypt is a free, automated, and open certificate authority that officially launched in April 2016. It was originally founded in 2012 by two Mozilla employees. Their goal for founding Let's Encrypt was really simple; to encrypt the e

HTTP2 Tutorial - The Past and Present of HTTP2

Publish Date:2025/03/16 Views:73 Category:NETWORK

HTTP was originally proposed by Timberners-Lee, a pioneer of the World Wide Web, who designed the application protocol with simplicity in mind to perform advanced data communication functions between web servers and clients. The first docum

HTTP2 Tutorial - The shortcomings of HTTP1.1

Publish Date:2025/03/16 Views:145 Category:NETWORK

HTTP 1.1 is limited to handling only one outstanding request per TCP connection, forcing browsers to use multiple TCP connections to handle multiple requests simultaneously. However, using too many TCP connections in parallel can cause TCP

HTTP2 Tutorial - HTTP2 Functional Upgrade

Publish Date:2025/03/16 Views:87 Category:NETWORK

Before we officially introduce the functions of HTTP/2, let's take a detour to understand the past and present of HTTP/2 . Multiplexing Streams The bidirectional sequence of text-formatted frames sent via the HTTP/2 protocol exchanged betwe

HTTP2 Tutorial - How to use HTTP/2 with HTTPS

Publish Date:2025/03/16 Views:84 Category:NETWORK

HTTPS is used to build ultra-secure networks connecting computers, machines, and servers to handle sensitive business and consumer information. HTTP/2 browser support includes HTTPS encryption, which actually complements the overall securit

HTTP2 Tutorial - How to Configure HTTP2 with Nginx

Publish Date:2025/03/17 Views:195 Category:NETWORK

HTTP2 was officially released in 2015. If your website is still using HTTP/1.1, you may be out of date. Don't worry, here we will see how to use Nginx to upgrade your website to HTTP2. Install Nginx I feel that this column is redundant. Sin

OAuth2.0 - A comprehensive understanding of OAuth2.0

Publish Date:2025/03/17 Views:72 Category:NETWORK

When I first came into contact with OAuth2.0, I often confused it with SSO single sign-on. Later, due to work needs, I implemented a set of SSO in the project. Through my gradual understanding of SSO, I also distinguished it from OAuth2.0.

Scan to Read All Tech Tutorials

Social Media
  • https://www.github.com/onmpw
  • qq:1244347461

Recommended

Tags

Scan the Code
Easier Access Tutorial