HTTP to HTTPS Redirect using .htaccess Print

  • 0

To redirect website from HTTP to HTTPS, you need to contain following code using .htaccess or web.config files which depends upon server you use.

Redirect HTTP to HTTPS using .htaccess

Linux & cPanel / BlueOnyx
You need to place below code in .htaccess file in the root directory of your website. This code forces users to redirect to HTTPS connection.

RewriteCond %{HTTPS} !on [OR]
RewriteCond %{HTTP_HOST} !^www\.
RewriteRule (.*) https://www.domainname.com%{REQUEST_URI} [L,R=301]

Be sure to replace "domainname.com" with your actual domain.


Was this answer helpful?

« Back