How Do I change the base URL in Drupal 8?

By gnanaguru, 17 August, 2022

There are 2 ways to change the base url of the Drupal website

1. Using .htaccess file
Add a .htaccess on the parent directory, and put the following text to it,

RewriteEngine on

#index page
RewriteRule ^$ drupal_website_path/index.php [L]

#the other pages
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* drupal_website_path/$0 [L]

2. Using setting.php file

Go to your Drupal directory, changed the settings.php file which locates at default/settings.php.
Change the $base_url to your domain url, such as $base_url = ‘http://www.webdevsupports.com’

Or

$config['base_url'] = 'http://www.webdevsupports.com';

Tags

Comments

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.