Moodle HTTP to HTTPS Problem

Moodle HTTP to HTTPS Problem

Adam Latrache -
回帖数:13

Hi all, 


Background info: 

I recently purchased an SSL cert for my main site (www.sfe-academy.co.uk) this has worked fine. However, the Moodle url also moved over to HTTPS from the HTTP standard. (moodle page = www.sfe-academy.co.uk/moodle)

The problem: 

Moodle login page does not load correctly with https://www.sfe-academy.co.uk/Moodle. I have to 'load unsafe scripts' in order for the login page to load correctly and to access Moodle itself. 

Images are stripped out and only text is visible. Issue probably caused by mixed content on the website. 

Once logged on to Moodle, JSON error messages appear when trying to save new info to the site and other random glitchy stuff happens. 

Moodle Version 3.5.3

What I have done so far: 

Enforced  https - disabled  - not an option as main is viewed as insecure too. 

Used Moodle https conversion tool - did not work. 


Panic levels = Ludicrous

Any advice and guidance on how to fix the issue would be great. 

回复Adam Latrache

Re: Moodle HTTP to HTTPS Problem

Leon Stringer -
Core developers的头像 Particularly helpful Moodlers的头像

Have you updated your config.php (in the root of Moodle's source code folder) to change the address in $CFG->wwwroot from HTTP to HTTPS?

回复Leon Stringer

Re: Moodle HTTP to HTTPS Problem

Adam Latrache -

Hi Leon 

Just changed config.php file as suggested. 

$CFG->wwwroot   = 'https://sfe-academy.co.uk/moodle';


No change unfortunately. 



回复Adam Latrache

Re: Moodle HTTP to HTTPS Problem

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
Your certificate is made with www before your domain. Your Moodle site has no www before the domain. You need to decide with or without www and stick to that.
回复Visvanath Ratnaweera

Re: Moodle HTTP to HTTPS Problem

Adam Latrache -

Hi Visanath 

Thank you for your post. However, I am not too sure how this would lead to a fix for the issue (or how to carry it out) 


Thank you, 

回复Adam Latrache

Re: Moodle HTTP to HTTPS Problem

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
How about
$CFG->wwwroot = 'https://www.sfe-academy.co.uk/moodle';
for a start?
回复Visvanath Ratnaweera

Re: Moodle HTTP to HTTPS Problem

Adam Latrache -

Hi, 


$CFG->wwwroot = 'https://www.sfe-academy.co.uk/moodle';  - no change 

Will a search and replace of http to https on the database have to be performed? so all requests are going through https instead of http? 



回复Adam Latrache

Re: Moodle HTTP to HTTPS Problem

Visvanath Ratnaweera -
Particularly helpful Moodlers的头像 Translators的头像
No, you haven't. The URL with www jumps back to without www. If you are sure you changed the $CFG, talk to the administrator of your web server/hosting.

P.S. About the "replace" tool. Read the warning very carefully, before you do it. There is no "undo" command!
回复Visvanath Ratnaweera

Re: Moodle HTTP to HTTPS Problem

Leon Stringer -
Core developers的头像 Particularly helpful Moodlers的头像

Following up from Visvanath's comment, I'm wondering if you're editing the correct config.php or if the changes are being saved correctly because these changes should have some effect and they don't seem to be.

If you look at the HTML source code for the site in your browser you'll see in the first few lines links to files needed for the home page and they're all http://... not https://.... This address is read from $CFG->wwwroot in config.php so if they're all still http then perhaps the live site source code is in a different folder with another config.php which is the copy that needs changing?

回复Adam Latrache

Re: Moodle HTTP to HTTPS Problem

Emma Richardson -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Yes, you need to update the database to correct all the links.  After doing that, you then need should flush the caches.

回复Adam Latrache

Re: Moodle HTTP to HTTPS Problem

Emma Richardson -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

Have you run the replace tool to update the database?

yoursite.com/admin/tool/replace/index.php

Visvaneth is saying that you either need to add www to your site's dns settings or remove it from the certificate - however, the site is loading so I don't think this is an issue right now.

I think you need to run the replace as noted above.

回复Emma Richardson

Re: Moodle HTTP to HTTPS Problem

Adam Latrache -

Hi Emma 


Thank you for your help. 


I have run the replace tool on Moodle but still no change at all. I have tried to force https in config file but still no change at all. 



回复Adam Latrache

Re: Moodle HTTP to HTTPS Problem

Emma Richardson -
Documentation writers的头像 Particularly helpful Moodlers的头像 Plugin developers的头像

And in the replace tool you went from http://www.yoursiteurl to https://www.yoursiteurl?

I would then run it again with http://yoursiteurl . to https://yoursiteurl to take care of any links that might not have the www in the address.

Then go into your moodleDATA (NOT CODE) folder and delete the cache and localcache folders.

If still no change, go look at the slash arguments setting in site admin and try changing it and see if that helps.

If none of that works, turn on full debugging and see if we get some error messages...

回复Emma Richardson

Re: Moodle HTTP to HTTPS Problem

Adam Latrache -

Hi all

Thank you very much for your contributions to this post. You have helped me learn a lot more about Moodle!

I have found the solution to the issue: 


Fix:

1. Go into CPanel of your server (I am using Apache

2. Go to Softaculous App installer ( or where ever you have installed Moodle) 

3. Go to 'edit installation details' 

4. Where it says 'url' make sure it states 'https' if it doesn't, simply edit the url (http to https)