Configuring your Moodle site to use SSL

moodleFor some Moodle sites, you'll want them to use SSL, so that all the traffic on the site is encrypted.  Particularly important if the site is used for financial transactions.

This article describes how to do this using the Siteground SSL Certificate, using the example of secure.mysite.com.


Subdomains

Before you get started, please note that you need to have the exact sub-domain as a symlink or a folder inside of the primary domain folder (for the SSL).

In order to do that, you can create the symlink by running the following command through SSH in the folder: /home/Addons/mysite.com where the domain for the SSL resides.

ln -s /home/Subdomains/mysite.com/secure/ secure

Note that if you are unsure how to create this symlink you can post a new ticket at Siteground and they will do it for you (for other sub-domains you wish to use through the secure connection).

Note, that adding a symlink, does not affect the Akeeba Backup on ras.ac.uk. In other words the symlinked /secure folder is not included when backing up using Akeeba Backup in the primary domain folder.

 

Moodle sites

  1. Navigate to the config.php file in the File manager.
  2. Look for the line 17 (on default config files) that shows:
$CFG->wwwroot = 'http://secure.mysite.com';

Change the http:// to https:// like the following:

$CFG->wwwroot = 'https://secure.mysite.com';

Next, Set up a redirect in your .htaccess file, by placing the following code to force the https:// redirect.

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

 

Thanks for visiting.