How do I force a redirect from http to https?

If you want to redirect your visitors to the secure version of your site, you can use the following example in your .htaccess file. It will force all visitors viewing your site with http > https.

RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]

 

Replace example.com with your domain name, once done visitors to http://example.com will be redirected to https://example.com.

  • 139 Users Found This Useful
Was this answer helpful?

Related Articles

Redirect to maintenance page during upgrade using .htaccess

Redirect your visitor to maintenance page is a must when you are upgrading your site. Now you can...

How do I redirect parked domains to the main account domain using mod_rewrite?

Sometimes to protect your brand you will have several domains relating to one site however you...

How do I force my website to use/not use the "www" prefix?

To force all website visitors to use either user the www. part of the domain or not in the URL...

Can I use mod_rewrite?

Mod_rewrite is an Apache web server module installed on all of our web servers by default, all...

Redirect to maintenance page during upgrade using .htaccess

Redirect your visitor to maintenance page is a must when you are upgrading your site. Now you can...