Ask Mommy and get Answers from experts
0 votes

How to Redirect HTTP to HTTPS using .htaccess File? 

in Websites by Newbie (320 points)

1 Answer

0 votes

To redirect all HTTP traffic to HTTPS, you can use server-side configurations.

You can use Apache's .htaccess file to redirect HTTP to HTTPS. Place the following code in your .htaccess file:

RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]

This code checks if HTTPS is off (RewriteCond %{HTTPS} off) and redirects to HTTPS (RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]).
by Silver (3.3k points)
44 questions
44 answers
7 users