# Changing the Moodle site URL

> Change the site URL of your Moodle installation in config.php after moving it to a new domain, server or directory.

Source: https://helpcenter.ruachost.com/apps/other-apps/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:

1. Access your account via SSH or cPanel.
2. Using the command line or cPanel File Manager, navigate to the Moodle installation directory.
3. Open the `config.php` file with your preferred text editor.
4. Locate the line beginning with `$CFG->wwwroot`.
5. Update the value with the new site URL, for example:

   ```
   $CFG->wwwroot   = 'https://example.com/moodle';
   ```
6. Save the `config.php` file. 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 under `public_html`)

## More information

- [Official Moodle documentation](https://docs.moodle.org/)
- [Moodle migration documentation](https://docs.moodle.org/38/en/Moodle_migration)
