Adding SSL and HTTPS in WordPress


SSL Certificate is a text file that contains encrypted data. SSL Certificate helps to make secure sensitive communications between your site and your customers.

You need to create a CSR (Certificate Signing Request) and purchase a certificate. Once your SSL Certificate has been signed and issued, you will able to download SSL Certificate. After that you need to install certificates on the hosting server.

Once you have your certificate installed, you can follow the below steps for using SSL in WordPress.

WordPress Configuration:

Now it’s time to configure the WordPress for using SSL Certificate and HTTPS redirect at your site. You need only three modifications for completing WordPress SSL configuration.

.htaccess File:

Open the .htaccess file and remove all the existing code and placed the below code. Don’t forget to change mysite.com with your domain name.

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.mysite.com/$1 [R,L]
</IfModule>
# END WordPress

wp-config.php File:

Open the wp-config.php file and insert the following code into this file.

define('FORCE_SSL_ADMIN'true);
define('FORCE_SSL_CONTENT'true);
if (
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'):
    
$_SERVER['HTTPS']='on';
endif;

Settings at WP Admin:

Go the the WP Admin General Settings page (Settings => General) and modify the WordPress Address (URL) and Site Address (URL) values from http:// to https://www.

add-https-url-in-wordpress-wp-admin-by-codexworld

Note that: Don’t forget to change all the hard coded links in https://www..

2 Comments

  1. Arkaprava Majumder Said...
    • CodexWorld Said...

Leave a reply

Connect With CodexWorld