When we modify the site of our Moodle installation, the website loads incorrectly and we cannot access it. This happens because, at the time of installing Moodle, the current path is recorded.
 
To modify the paths, we need to edit the Moodle configuration file called config.php, which is located in the directory where the application is installed.
 
To edit it, we can download it via FTP and edit it using a text editor.
 
When editing it, we must modify the line that indicates the URL where Moodle is installed.
 
$CFG->wwwroot = 'http://www.example.com';
 
Simply change the domain name and/or the current folder to the domain and/or folder where Moodle is installed. 
 
If Moodle is located inside a folder, it would look like this:
 
$CFG->wwwroot = 'http://www.example.com/folder';
 
In the same file, there is another line that we must modify, located just below the previous one. This line indicates where the moodledata directory is located, where the application stores information. 
 
$CFG->dataroot = '/usr/home/example.com/moodledata';
 
In this case, we only modify the domain name with the new one. 
 
Delete the cache folder
The final step to make Moodle work again after modifying the associated domain is to delete the cache folder located inside the moodledata directory. 
 
Simply delete the cache folder through the FTP manager.
 
Once all these changes have been made, Moodle should work correctly and allow access to its administration panel.
  
For more information, you can contact us.