- 1 year ago
Moodle 3.9.19 http-https redirect problem, how to solve it?
To redirect HTTP to HTTPS in Moodle 3.9.19, follow these steps:
Enable HTTPS for your Moodle site. You can use a free SSL certificate from Let's Encrypt or purchase a commercial SSL certificate from a trusted certificate authority.
Open your Moodle site's
.htaccess
file in a text editor. If the file does not exist, create it in the root directory of your Moodle installation.Add the following code to the
.htaccess
file to redirect HTTP requests to HTTPS:perlRewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Save the changes to the
.htaccess
file.Test the redirection by accessing your Moodle site using HTTP. The browser should automatically redirect to HTTPS.
Note: If you are using a reverse proxy or load balancer in front of your Moodle site, you may need to configure it to pass the X-Forwarded-Proto
header to Moodle so that Moodle can correctly detect the protocol used by the client.