Forcing your wordpress site to use https

Hello, today we will force our wordpress site to use https instead of http
You can use plugins or somethink else
but the proper way to force your site use https is editing .htaccess
In fact, doing something wrong with .htaccess can cause your site to crash and more
So lets start our Guide
If you setup your wordpress your .htaccess should look like this

#BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
 
# But adding a simple sentence can force your site to use https
# END WordPress
RewriteEngine on
RewriteCond %{HTTPS} !=on [NC]
RewriteRule ^(.*)$ https://yoursiteurl.com/$1 [R=301,L]

Finaly there is alot of ways to force your site to use https i show the way that redirects to https you can use cloudflare but this can be enough to force your site to use https
Don’t forget you need an ssl certificate to use https
Have a nice day hope you force your site to use https :slight_smile:

3 Likes

I showed how to force your site use https without using plugins.
Thanks, who don’t want to edit .htaccess can use plugin but don’t forget you can force your site use htttps without using plugins.

I haven’t vetted this article so I don’t know if it works. But our official guide recommends a slightly different .htaccess snippet:

And the Really Simple SSL plugin is very nice.

4 Likes

I hate really simple ssl it causes my site crash.
This problem may only be for me but I do not recommend it.

And do note to put the htaccess file/code files in code blocks so that people can use it with ease :+1:

5 Likes

Another way will be to use InfinityFree SSL tool to install SSL cert. Then add the custom domain to CloudFlare. Last step will be to change SSL mode to full or full(strict) within CF. No .htaccess modification will be needed.

For those who find renewing SSL cert every 3 mths a hassle, get a self -signed cert from
https://www.selfsignedcertificate.com/

This method will only work with custom domain.

after I typed my url…

I prefer this method.

No issue for me. Most likely your ISP or network…

SSL is valid for 10 yrs.

1 Like

Gr8!

Did you test this? The control panel should not accept self signed certificates.

1 Like

Yes, it worked.
Installed successfully.

1 Like