How to force redirect HTTP to HTTPS Using .htaccess
In this tutorial, we will learn How to force redirect HTTP to HTTPS Using the .htaccess Example. We will explain redirect HTTP to HTTPS Using .htaccess. We use RewriteRule to force redirect HTTP to HTTPS.
I would like to share redirect HTTP to HTTPS Using the .htaccess Example. In this tutorial, you will learn How to force redirect HTTP to HTTPS Using the .htaccess Example. And if you want to see an example of How to force redirect HTTP to HTTPS Using .htaccess, then you are in the right place.
Mostly, Chrome and Firefox have showing insecure warnings on sites without SSL(Secure Sockets Layer) certificates installed.
Table of Contents
- Redirecting HTTP to HTTPS
- Redirect specific domain
- Redirect specific folder
Note: First, backup your website in case something goes wrong.
Redirecting HTTP to HTTPS
We will add redirecting HTTP to HTTPS.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.devnote.in/$1 [R,L]
Redirect specific domain
We will add redirecting a specific domain to use HTTPS.
RewriteEngine On
RewriteCond %{HTTP_HOST} ^devnote\.com [NC]
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.devnote.in/$1 [R,L]
Redirect specific folder
We will add redirecting to HTTPS on a specific folder.
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteCond %{REQUEST_URI} folder
RewriteRule ^(.*)$ https://www.devnote.in/folder/$1 [R,L]
Note: Replace devnote with your actual domain name wherever required.
Learned something new & It works for me. For further implementation in shared Cpanel hosting or some advanced redirecting technique, please check this way easily.
https://flamontech.com/how-to-redirect-http-to-https-using-htaccess/