Moodle not working after installing certificate on site

Moodle not working after installing certificate on site

by Yanis Sauve -
Number of replies: 4

Hello,

Moodle running on IIS.

Since I installed an SSL certificate, all pages do not display properly, since the PHP code generates absolute URLs to http://hostname/moodle in the code returned to the browser.  This causes the browser to not run scripts that come from http, while the page itself is https (of course)

Is there a way to change this behaviour to either have absolue URLs to https://hostname... or, even better, relative URLs altogether?

Thanks

Average of ratings: -
In reply to Yanis Sauve

Re: Moodle not working after installing certificate on site

by Bret Miller -
Picture of Particularly helpful Moodlers

Could be a couple of things, actually. First, make sure your config.php has the correct URL for the site:

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

Also, changing the URL (and a change from http to https IS a change in the URL), you may need to run the search/replace tool to replace the old URL with the new URL in the database. See the "Moodle Migration" doc to learn about the tool.

In reply to Bret Miller

Re: Moodle not working after installing certificate on site

by Yanis Sauve -

Ok.  Somebody on the french side of the forums suggested this also, but did not speak specifically of the variable in config.php.

So, if I:

1 - Make sure $CFG->wwwroot = 'https://hostname/blahblah...' is properly set in config.php

2 - Use the replace tool to change all instances of "http://hostname" to "https://hostname" in the DB

3 - Restart the server

...that should do the trick?

I do have a question about #2.  How specific should I be with the replace tool? is "http://" to "https://" specific enough?  Or should I go with "https://hostname/moodlename"?

Thanks

In reply to Yanis Sauve

Re: Moodle not working after installing certificate on site

by Emma Richardson -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Go with the full url so as not to mess with any other external links that you may have on site.

In reply to Emma Richardson

Re: Moodle not working after installing certificate on site

by Yanis Sauve -

Hello all,

It worked perfectly.

Here's what I did, for reference:

1 - Backed-up config.php and MySQL databases

2 - Modified config.php:  Made sure $CFG->wwwroot is pointing to the right URL, that is "https://hostname/moodle"

3 - Used the replace tool (http://hostname/moodle/admin/tool/replace/index.php) to find and replace all instances of "http://hostname/moodle" and replace them with "https://hostname/moodle"

4 - Used the purge cache tool (https://hostname/moodle/admin/purgecaches.php) to remove all old references that could still be in there, and force user's browsers to reload content from the site.

Replace "hostname/moodle" in these steps to reflect where your Moodle installation is located.

Big thanks to all of you for your help and time.

Average of ratings: Useful (1)