I have functionality that relies on having $base_url set in the settings.php file, but I have a multidomain site in order to keep languages separate.

The sections of my site are www.mysite.com and www.de.mysite.com. If I set base_url to "www.mysite.com" I get German language content on www.mysite.com.

How do I set the base_url for a multi-domain, multi-lingual setup so that things like my image style generation can work correctly?

This is a single install, not multisite.


It looks like you have 1 site in sites/www.mysite.com in your drupal setup and are trying to avoid having sites/www.mysite.com and sites/www.de.mysite.com ... ? So you're trying to edit 1 settings.php file.

You could create the above drupal sub-sites .... or try this less invasive approach.

Create a sites.php file if you're using Drupal 7 (you didnt specify your drupal version).

See this documentation page on sites.php It allows you to define configuration folders (where settings.php lives) per site in an array. This file is placed at DRUPAL_ROOT/sites/sites.php

// contents of sites.php
// URL = folder in sites directory.
$sites['www.mysite.com'] = 'mysite.com';
$sites['www.de.mysite.com'] = 'de.mysite.com';

// make a settings.php with unique $base_url in each directory above.

@kalabro's response is basically the same, except this is trumping the auto-discovery behavoir and making the settings directory explicitly set in PHP code.

|improve this answer|||||

I guess you need separate settings.php file for each site. You can create special folder for each domain in your sites directory and set custom $base_url in each settings.php file.

+-- all
¦   +-- modules
¦   +-- README.txt
¦   L-- themes
+-- default
¦   +-- default.settings.php
¦   +-- files
¦   L-- settings.php
L-- de.mysite.com
    L-- settings.php
L-- ru.mysite.com
    L-- settings.php

Documentation about site folders: http://drupalcode.org/project/drupal.git/blob/c5d6e6334fb7a71ecf1dbc7e06a7de8ad9547b27:/sites/default/default.settings.php#l25

|improve this answer|||||
  • This is not a multisite install. It's a multiple-subdomain single site. – beth Jan 29 '13 at 22:48
  • @beth I guess It doesn't matter. – kalabro Jan 31 '13 at 10:19
  • @beth did you find a fix for this? I have the same issue. I don't want to seperate the site into a multi-site architecture, but find a way to set 2 different base_url depending on the domain. – Julien Charette Jun 10 '15 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.