Skip to content

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.

  • 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

Section titled “Steps to Change the Base URL in Drupal 8 and 9”
  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.
  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.
  1. Upload the modified .sql file back to your hosting account.
  2. Use phpMyAdmin or the command line to import the updated database.
  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.
  • 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.