Drupal - How do I change the base URL?

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

Edit:

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: https://www.drupal.org/node/2753591


I thought once some kind of tweaks were needed when moving between production (http:// example.com/) and dev (http:// localhost/~aviram/example.com/). 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 (http://example.com/update.php) 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.

Tags:

Uri

8