Changing the Moodle site URL
Changing the Moodle site URL
This article explains how to change the site URL for a Moodle installation. This may be necessary if you migrate Moodle to a new server or move it to a different directory on the same server.
Changing the site URL
To update the site URL for Moodle, follow these steps:
-
Access your account via SSH or cPanel.
-
Using the command line or cPanel File Manager, navigate to the Moodle installation directory.
-
Open the
config.phpfile with your preferred text editor. -
Locate the line beginning with
$CFG->wwwroot. -
Update the value with the new site URL, for example:
$CFG->wwwroot = 'https://example.com/moodle'; -
Save the
config.phpfile. The new site URL is now active.
Tip
If you are migrating Moodle, verify other values in config.php to ensure they are correct:
$CFG->dbname: Moodle database name$CFG->dbuser: Moodle database username$CFG->dbpass: Moodle database password$CFG->prefix: Table prefix for the Moodle database$CFG->dataroot: Data root directory for Moodle (for security, this should not be underpublic_html)