# Changing the absolute path (base URL) in Drupal 8 and 9

> Change the base URL of a Drupal 8 or 9 site by exporting the database, updating the old URL and importing it again.

Source: https://helpcenter.ruachost.com/apps/drupal/changing-the-absolute-path-base-url-in-drupal-8-and-9/

In Drupal 7 and earlier versions, you could change the base URL by modifying the `$base_url` variable in the `sites/default/settings.php` file. However, in **Drupal 8 and 9**, the `$base_url` setting is deprecated and no longer used. Instead, you must update the base URL directly in the Drupal database. On **ruachost.com**, this ensures your site points to the correct domain after migration or rebranding.

## Why Change the Base URL?

- Update your site after moving to a new domain.
- Ensure consistency across all internal links.
- Fix issues after migration or staging site deployment.

## Steps to Change the Base URL in Drupal 8 and 9

### Step 1: Export the Database

1. Log in to your hosting account at **ruachost.com**.
2. Use **phpMyAdmin** or the command line to export your Drupal database.
3. Save the exported `.sql` file to your local computer.

### Step 2: Modify the Base URL

1. Open the exported `.sql` file in a text editor.
2. Find all instances of the **old URL**.
3. Replace them with the **new URL**.
4. Save the changes.

### Step 3: Import the Modified Database

1. Upload the modified `.sql` file back to your hosting account.
2. Use **phpMyAdmin** or the command line to import the updated database.

### Step 4: Test the Site

1. Open your Drupal site in a browser.
2. Verify that all links and resources load correctly.
3. Confirm that the new base URL is applied consistently.

## Important Notes

- Always back up your database before making changes.
- Use **search and replace carefully** to avoid breaking serialized data.
- Test thoroughly after importing the modified database.
