When managing a Moodle site, there are reasons to make the entire Moodle site work on an https:// connection. This will make all data transmitted over the site to be encrypted on an SSL connection. To achieve this, the Moodle config.php file will need to be edited and the .htaccess will need to have a redirect set up to force the https:// to load. The following tutorial will explain how to force Moodle 2.3 to work over an SSL connection.

Forcing SSL on https for Moodle

  1. Log into cPanel
  2. force-ssl-1-non-moodleNavigate to the config.php file in the File manager.

    Look for the line 17 (on default config files) that shows:

    $CFG->wwwroot   = 'http://yourdomain.com';
    

    force-ssl-2-ssl-moodle Change the http:// to https:// like the following:
    $CFG->wwwroot   = 'https://yourdomain.com';
    

     


  3. force-ssl-3-htaccess-moodleNext, Set up a redirect in your .htaccess file. Place the following code to force the https:// redirect.
    RewriteEngine On 
    RewriteCond %{SERVER_PORT} 80 
    RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
    
    Save the .htaccess file.

This concludes the article on Forcing Moodle 2.3 to work over SSL. For more information on this Education course please visit Moodle site security and server settings

Continued Education in Course 201: Moodle site security and server settings
You are viewing Section 2: Forcing Moodle 2.3 to work over SSL
Section 1: Setting the Moodle login to work over HTTPS
Section 3: Blocking IP's in the Moodle Site administrator
Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-08-21 2:25 am

Hi,

your post is informative.

In case if the moodle site is a subsite which is not a root site then how should the redirect code look like.

Thanks

Staff
19,412 Points
2014-08-21 7:52 am
Hello Das,

What do you mean a subsite? Did you mean a subdomain like 'moodle.example.com'? If so, the SSL would need to have been created with that in mind. The code would be almost identical, simply replacing example.com with subdomain.example.com

Kindest Regards,
Scott M

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

3 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!