Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set the base url in drupal

Where I can set the base url for drupal site. Currently when I go to the site in my localhost, it redirects to the original site. Please help me.

I have tried setting the $base_url in the sites/default/settings.php

Here is the portion where I set the base url

/**
 * Base URL (optional).
 *
 * If you are experiencing issues with different site domains,
 * uncomment the Base URL statement below (remove the leading hash sign)
 * and fill in the URL to your Drupal installation.
 *
 * You might also want to force users to use a given domain.
 * See the .htaccess file for more information.
 *
 * Examples:
 *   $base_url = 'http://www.example.com';
 *   $base_url = 'http://www.example.com:8888';
 *   $base_url = 'http://www.example.com/drupal';
 *   $base_url = 'https://www.example.com:8888/drupal';
 *
 * It is not allowed to have a trailing slash; Drupal will add it
 * for you.
 */
# $base_url = 'http://www.example.com';  // NO trailing slash!
$base_url = 'http://localhost/mysite';  // NO trailing slash!
like image 901
Dijo David Avatar asked May 04 '11 05:05

Dijo David


People also ask

How do I change the base URL in Drupal?

In order to locate the file , open the directory where you have Drupal installed , there proceed to the sites folder-> default-> settings. php. # $base_url = 'http://www.example.com'; There place your new URL and remove the # at the front.

Where is base URL in Drupal?

The settings. php file is the main configuration file for a Drupal site where a number of system variables, among other things, may be configured. In Drupal 7, there is an optional setting, $base_url , which specifies the absolute URL of the installation.

How do I find base URL in Drupal 8?

You can use url() to generate a base url to any route in Drupal. You can supply the <front> route which, in effect, will be your base URL.


1 Answers

Usually you don't need to set base_url, you simply have to clear drupal cache.

like image 164
soju Avatar answered Oct 13 '22 21:10

soju