Skip to main content

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File

Today, We want to share with you SSL forcefully Redirect HTTP to HTTPS Using .htaccess File.In this post we will show you How to force SSL using the .htaccess file , hear for How to redirect HTTP traffic to HTTPS using an .htaccess file we will give you demo and example for implement.In this post, we will learn about Redirecting HTTP to HTTPS Using .htaccess File: Step by Step with an example.

SSL forcefully Redirect HTTP to HTTPS Using .htaccess File

There are the Following The simple About SSL forcefully Redirect HTTP to HTTPS Using .htaccess File Full Information With Example and source code.

Also Read :  Top 10 MySQL Interview Questions and Answers

As I will cover this Post with live Working example to develop Force your site to load securely with an .htaccess file, so the some Redirect HTTP to HTTPS automatically for this example is following below.

Step 1: first of all simple Editing your .htaccess in main cPanel goto File Manager

Step 2: Sign In to cPanel

Step 3: and then Go to The Files > your File Manager > and Document main Root for:

Step 4: After that choose the tour domain name We want to get access

Step 5: Now a new open tab or window main file opens, look for the name as a .htaccess file.

Also Read :  JavaScript Dynamic Input Form Example

Step 6: .htaccess redirect http to https

Redirecting HTTP to HTTPS Using .htaccess File

RewriteEngine on

# force ssl
RewriteCond     %{SERVER_PORT} ^80$
RewriteRule     ^(.*)$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]

Note: Please get Your .htaccess file and all the Backup your main Data website in case all the something goes wrong.

Redirect All Web Traffic

RewriteEngine On 
RewriteCond %{SERVER_PORT} 80 
RewriteRule ^(.*)$$1 [R,L]

Redirect Only a Specific Domain

Simple redirecting a specific main My domain Working on SSL forcefully to use HTTPS

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

Angular 6 CRUD Operations Application Tutorials

Read :


You can also read about AngularJS, ASP.NET, VueJs, PHP.

Also Read :  Display JSON Data from database using php using jquery ajax

I hope you get an idea about SSL forcefully Redirect HTTP to HTTPS Using .htaccess File.
I would like to have feedback on my blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Web Developer

Hi, I’m Web developer, PHP is the most popular Programming & Web Development blog. Our mission is to provide the best online resources on programming and web development.Any visitors of this site are free to browse our tutorials, live demos, Examples and download scripts.If you have a project that you want to get started, launch quickly, contact me. Email : [email protected]