How to redirect a website from HTTP to HTTPS
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:
- Google announced that websites using HTTPS will receive a slight ranking priority in Google searches.
- Thanks to browser support, we can achieve faster performance using the new HTTP/2 protocol, which requires HTTPS.
- HTTPS is more secure and your visitor's data is fully encrypted.
- HTTPS establishes trust by enabling the green lock icon in the address bar of your visitor's web browser.
- 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.
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
If your web server is running Apache, you can .htaccess
easily 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.
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.
Related Articles
Redirection in PHP
Publish Date:2025/04/13 Views:158 Category:PHP
-
header() We will demonstrate another way to redirect a page in PHP using the function by sending an HTTP header to the browser . This method uses the built-in header() function in PHP, which takes Location as a parameter, and its value is t
Linux data stream bidirectional redirection command tee
Publish Date:2025/04/08 Views:177 Category:OPERATING SYSTEM
-
The tee command is a member of the Linux pipe command family. Its function is to redirect data to a file. We know that data redirection can be done directly using . Yes, can redirect data streams. But it cannot redirect data to standard out
Apache2.4 installation and precautions under Windows7
Publish Date:2025/04/08 Views:125 Category:OPERATING SYSTEM
-
To install apache2.4 in Windows 7, we first need to download the apache2.4 installation program. Here we download the software from the apache official website http://httpd.apache.org/download.cgi . First, let's see how to download apache2.
How to use Let's Encrypt with Nginx to configure https in Ubuntu 20.04
Publish Date:2025/04/07 Views:123 Category:OPERATING SYSTEM
-
Let's Encrypt is a Certificate Authority (CA) that provides an easy way to obtain and install free TLS/SSL certificates, enabling encrypted HTTPS on your web server. It simplifies the process by providing a software client, Certbot, which a
Linux iptables: Incoming and Outgoing Rules Example (SSH and HTTP)
Publish Date:2025/04/07 Views:125 Category:OPERATING SYSTEM
-
In our previous article in the iptables firewall series, we reviewed how to iptables -A add firewall rules using . We also explained how to allow incoming SSH connections. At a high level, it involves the following 3 steps. Delete all exist
How to Append Text to a File Using Bash
Publish Date:2025/04/05 Views:83 Category:OPERATING SYSTEM
-
We can use the redirection ( ) operator and tee the command to append text to a file. We have to make sure we have enough permissions to add text to the file. If we don't have enough permissions, we may get a permission denied error. Use th
Redirecting Stderr and Stdout to a file in Bash
Publish Date:2025/03/23 Views:187 Category:OPERATING SYSTEM
-
In this article, we will discuss standard output and standard error in Linux. We will see how to redirect standard output and standard error in Bash. Let us start by understanding the terms standard output and standard error in Linux. Stand
Redirecting output to a text file from within a batch file
Publish Date:2025/03/20 Views:187 Category:OPERATING SYSTEM
-
This article will explain different ways to redirect output from a text file. Redirection operators in batch scripts We can redirect the output of a batch file to a text file using redirection operators. Redirection operators redirect the i
How to Fix the “SSL Handshake Failed” Error (5 Methods)
Publish Date:2025/03/16 Views:98 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