How to force HTTPS on your website
Once your site has an SSL certificate, make sure every visitor uses the secure https:// address. Otherwise people who type your domain, or follow old links, may still land on the insecure http:// version.
Use one of the methods below, not several. Setting up the same redirect twice can cause a redirect loop.
WordPress
Section titled “WordPress”- Go to Settings → General.
- Change both WordPress Address (URL) and Site Address (URL) to start with
https://. - Click Save Changes and log in again.
Most WordPress sites then redirect automatically. If some pages still load over http://, add the .htaccess rule below.
cPanel: Force HTTPS Redirect
Section titled “cPanel: Force HTTPS Redirect”- In cPanel, open Domains.
- Find your domain and switch Force HTTPS Redirect to On.
This is the simplest option for non-WordPress sites.
.htaccess rule
Section titled “.htaccess rule”Add these lines at the top of the .htaccess file in your site’s folder (usually public_html). Use File Manager, and turn on Show Hidden Files to see .htaccess.
RewriteEngine OnRewriteCond %{HTTPS} offRewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]Ruachost servers run LiteSpeed, which reads .htaccess rules like Apache does.
Also choose www or non-www
Section titled “Also choose www or non-www”To send everyone to one address, for example https://www.example.com, use this instead (replace example.com with your domain):
RewriteEngine OnRewriteCond %{HTTPS} off [OR]RewriteCond %{HTTP_HOST} !^www\. [NC]RewriteRule ^(.*)$ https://www.example.com%{REQUEST_URI} [L,R=301]Using Cloudflare?
Section titled “Using Cloudflare?”Set Cloudflare’s SSL/TLS mode to Full or Full (strict), not Flexible, before forcing HTTPS here. Flexible mode with a redirect on the server causes an endless loop.
After switching
Section titled “After switching”- Test your site in a private browser window.
- If the padlock is missing or shows a warning, some content is still loading over
http://. See Fixing mixed content warnings. - Optional, for extra security: enable HSTS.