Changing the absolute path (base URL) in Drupal 8 and 9
This article describes how to change the absolute path (base URL) in Drupal 8 and 9.
This article describes how to change 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. In Drupal 8 and later versions, however, the $base_url setting is deprecated and no longer used.
However, you can update the base URL directly in the Drupal database. The following steps demonstrate how to do this.
Step 1: Export the database
First, export the current Drupal database to a file and download the file to your local computer.
Tip
For information about how to export a MySQL database, please see this article.
Step 2: Change the base URL in the database
After you have a file of the exported Drupal database, you are ready to make the changes to the base URL. To do this, follow these steps:
-
Using your preferred text editor, open the exported SQL file.
-
Find all instances of the old URL, and replace them with the new URL.
-
Save your changes to the exported SQL file.
Step 3: Import the modified database
Next, upload to your hosting account the database file that you modified in step 2, and then import it into the Drupal database.
Tip
For information about how to import a MySQL database, please see this article.
Step 4: Test the Drupal site
View the Drupal site in your web browser and make sure everything works as expected.
Related Articles
Updated 1 day ago