Force HTTP to HTTPS Redirect with htaccess file

To set up HTTP to HTTPS redirect, you need to add the following code to your .htaccess file.

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  • SSL, Redirection, htaccess
  • 233 Users Found This Useful
Was this answer helpful?

Related Articles

Fix Too Many Redirects Errors on WordPress After Moving to SSL / HTTPS

WordPress allows you to enforce SSL / HTTPS for the admin area by entering the following line...

Public IP SSL Files for Apache, Nginx and IIS

The key is always the same for Apache, Nginx and IIS. It's the one you got at the very first when...