I'm upgrading a multi-language site from EE1 to EE2, and it's using the technique of duplicating index.php and path.php inside subdirectories named for each language, and defining global language variables inside path.php.

So I upgraded the site to EE2, ditched the path.php files from the subdirectories, updated the index.php files to the new EE2 versions, and added these configuration variables:

$assign_to_config['site_url'] = (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') ? 'https://' : 'http://' . $_SERVER['HTTP_HOST'] . '/en/';

$assign_to_config['global_vars'] = array(
    'country_code' => 'en',
    'language' => 'english'

The global variables seem to be working, but site_url is not. I tried:

  • $config['site_url'] = '...'

  • $site_url = '...'

I'm also using Focus Lab Master Config, and I made sure to comment out the $env_config['site_url'] variable inside config.master.php. I also double-checked that it's not being defined inside system/expressionengine/config/config.php.

What am I doing wrong here?

UPDATE: The site_url global variable works when used in templates, but it isn't applied in the control panel, in Admin > General Configuration, for example.

I'm using FocusLab Master Config, and assigning site_url from within config.master.php does update the control panel. So there must be something getting in the way somewhere between index.php and config.master.php.


Does it work when you hard code the site URL?

How about:

$assign_to_config['site_url'] = getenv('HTTP_HOST');

Have you ensured your system path has been altered in index.php?

$system_path = '../system';

Notice the extra leading dot.

  • Hard-coding the URL doesn't work either, and yes, the system path is correct.
    – kmgdev
    Mar 29 '13 at 20:17
  • How about trying to append the /en/ if you have a sub-directory setup: $site_url = "domain.com/en"; ?
    – Ian
    Mar 29 '13 at 20:33
  • Also, check what's in your database (set via the control panel) as assign_to_config[] might not be overriding that setting the same way that config[] does in config.php
    – Ian
    Mar 29 '13 at 20:34
  • hmm...odd. I was basing my question off of the fact that the Site URL in the control panel's General Configuration section wasn't changing, but I just checked my template output, and the {site_url} variable is outputting the correct URL for all languages and the naked homepage URL. I don't understand why the config variable isn't updating the control panel/DB setting though - I thought that was the whole point?
    – kmgdev
    Mar 29 '13 at 23:19
  • 1
    Is it not updated in both Admin > General Configuration and in Admin > System Administration > Config File Editor? I've not used the Focus Lab Master Config before but check to make sure nothing in there is overriding those values.
    – Ian
    Mar 30 '13 at 13:05

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.