
This forces every visitor to the encrypted version of your site, even if they type or link to the plain http:// address.
Before you start
Make sure SSL is already active on the domain (it is, by default, through AutoSSL - see what an SSL certificate is) before adding this redirect, or visitors will be sent to a page that doesn't load.
Adding the redirect
|
|
|
RewriteEngine on
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
|
| Using Cloudflare? If your domain's traffic passes through Cloudflare, set the SSL/TLS mode in the Cloudflare dashboard to Full or Full (strict) before adding this rule. On Flexible mode, Cloudflare talks to this server over plain HTTP, so the server always sees %{HTTPS} off and redirects forever - an endless redirect loop that never finishes loading. |
|
Redirect loop or site not loading after this? We'll take a look. Open a support ticket |
Testing it, and the WordPress way
- In the browser: open a private window and type the address with http://. It should end up on https:// with the padlock. The private window avoids an old redirect the browser may have kept.
- On the command line:
curl -I http://yourdomain.comshould answer301 Moved Permanently, with aLocationline pointing to the https:// address. - On WordPress: also change WordPress Address and Site Address to https:// in Settings > General. If you would rather not edit .htaccess, an SSL plugin can do the redirect for you. Use one redirect method, not two stacked.
- A padlock with a warning (mixed content): the page is on https, but some image, script or style is still called with http://. The redirect does not fix that: replace the old addresses in the content (on WordPress, a search and replace plugin does it in the database). The certificate itself is issued by AutoSSL in the panel, at no cost.
|
SEE ALSO Why does my SSL certificate show fewer than 365 days? How to tell if your site has been compromised |
|
SSL CERTIFICATES The padlock your customers look for. A paid certificate adds warranty and company validation - useful for online shops and any site taking payments or customer data. See SSL certificatesHosting already includes free SSL for everyday use |
RECOMMENDED PRODUCT Web hosting with cPanel Domain and SSL included, daily backups and the panel you already know. from $6.60/mo (3-year plan, with coupon) See plans |











