Redirect HTTP traffic to HTTPS using an .htaccess

Create a .htaccess file then write this code you will redirect all HTTP traffic to HTTPS.

##Global Http to Https Redirect 
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]

If you want a single page to redirect http to https then use this code.

## single page redirect
RewriteEngine On
RewriteRule ^redirect-http-to-https-page\.html$ https://www.example.com/redirect-http-to-https-page.html [R=301,L]

Comments

comments