How do I change the base URL?

In Drupal 7, we can quickly change the base URL of the website.
How can I do this, in Drupal 8?

Answers 2

  • In Drupal 8 this option has been removed. You don't have to configure base_url to run your site. Drupal 8 can detect this without your help. If not, you should first check your webserver configuration.

    Instead of base_url you should configure trusted_host_patterns in settings.php. This is not needed to run the site, but important for security reasons.

    More info: Removed base_url option from settings.php and New setting for trusted hostname configuration


    There are some special use cases when running drupal from command line or reverse proxy, that used $base_url in the past. This can no longer be supported in the same way because of symfony. There is a discussion going on how to provide a solution for these cases. This does not mean that you cannot run drupal from the command line or reverse proxy. The standard way is of course possible without problems.

    You can follow the development here:

  • I thought once some kind of tweaks were needed when moving between production (http:// and dev (http:// localhost/~aviram/ But no, D8 is smart enough to fix links automatically.

    After moving a complete site (PHP files and DB dump), just go through the D8 database update process ( even if there is no update for the database model. This fixes the problem.

    I learned this is a Drupal 8 cache-related problem probably because some pre-rendered content is kept in sites/default/files/php/. And the update.php process somehow cleans this cache.

Related Questions