A Simple Guide to Redirect HTTP to HTTPS with .htaccess – WordPress Tips

By | June 21, 2019

To redirect site http to https in wordpress,  the most easy way is to use wordpres plugin.

Force WordPress Redirect Http to Https with Easy HTTPS (SSL) Redirection

However, if you do not want to use wordpress plugin, you also can use .htaccess to redirect http to https.

If you do not know how to open and edit wordpress .htaccess, you can refer this article.

An Easy Way to Edit WordPress .htaccess with Yoast SEO Plugin

In this article, we instroduce some examples to redirect http to https with .htaccess.

Example 1. Redirect All site HTTP URLs to HTTPS

Add the following code to your .htaccess file

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

Example 2. Redirect Only a Specific HTTP Domain to HTTPS

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

Example 3. Redirect Only a Specific Folder

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

Note: Replace “yourdomain” with your actual domain name wherever required. Also, as to folder, replace /folder with the actual folder name.

Leave a Reply