how to redirect HTTP to HTTPS using htaccess file – onlinecode

how to redirect HTTP to HTTPS using htaccess file – onlinecode

In this post we will give you information about how to redirect HTTP to HTTPS using htaccess file – onlinecode. Hear we will give you detail about how to redirect HTTP to HTTPS using htaccess file – onlinecodeAnd how to use it also give you demo for it if it is necessary.

Today, in this article, we will explain to you how to redirect HTTP to HTTPS using htaccess file. it has forces any HTTP request to redirect to HTTPS using the below example.

If you have a purchase SSL certificate and http://www.example.com domain. and you want to redirect to https://www.example.com. it is possible to the .htaccess. first, create a .htaccess file in your root project directory and paste the following code.

see the following code example.

Redirect All Web Traffic

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

Redirect Only a Specific Domain

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

Redirect Only a Specific Folder

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

Force Any HTTP Request to Redirect to HTTPS

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

Please follow and like us:

Hope this code and post will helped you for implement how to redirect HTTP to HTTPS using htaccess file – onlinecode. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

6  +  2  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US