> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Changing the Moodle site URL

> If you want to change the URL for an existing Moodle installation, this article shows you how!

This article describes how to change the site URL for a Moodle installation. You may need to do this, for example, if you migrate an existing Moodle installation to a new server. Alternatively, you may want to relocate a Moodle installation to a new directory on the same server.

## Changing the site URL

To change the site URL for a Moodle installation, follow these steps:

1. Access your account using [SSH](/docs/using-ssh-secure-shell) or [cPanel](/docs/accessing-cpanel).

2. Using the command line or cPanel File Manager, navigate to the directory where Moodle is installed.

3. Using your preferred text editor, open the *config.php* file.

4. Locate the line in the file that begins **\$CFG->wwwroot**.

5. Update the corresponding value with the new site URL. For example:

```
$CFG->wwwroot   = 'https://example.com/moodle';
```

6. Save your changes to the *config.php* file. The new site URL is now active.

<Tip>
  If you are migrating a Moodle installation, you should check other values in the *config.php* file and ensure they are correct. For example, verify that the following database and data directory settings are correct:

  * **\$CFG->dbname:** This is the Moodle database name.

  * **\$CFG->dbuser:** This is the username for the Moodle database.

  * **\$CFG->dbpass:** This is the password for the Moodle database.

  * **\$CFG->prefix:** This is the table prefix used in the Moodle database.

  * **\$CFG->dataroot:** This is the data root directory for the Moodle installation. For security reasons, this directory should **not** be located under the *public\_html* directory.
</Tip>

## More information

* To view the official online Moodle documentation, please visit [https://docs.moodle.org](https://docs.moodle.org).

* To view documentation about Moogle migrations, please visit [https://docs.moodle.org/38/en/Moodle\_migration](https://docs.moodle.org/38/en/Moodle_migration).

## Related articles

* [Moodle](/docs/moodle-configuration)
