1

I have set up environments in my config file and included a different siteUrl for each. This is so I can change the navigation on the fly.

I have noticed however that siteUrl when defined in the CP is being used instead of the defined value in the config file. I was under the impression that the CP setting for siteUrl got ignored. What am I doing wrong?

I'm using the same database across both environments - would that be an issue?

return array(
     '*' => array(
         // ...
     ),
     // Local Dev
     'test.dev' => array(
         // ...
         'devMode' => true,
         'environmentVariables' => array(
             'assetsBasePath' => '/Users/joebloggs/Sites/work/example/shop/assets/',
             'assetsUrl' => 'http://test.dev/shop/assets/',
             'siteUrl'  => 'http://test.dev/',
         )
     ),
     // Live Dev
     'test.example.com' => array(
         // ...
         'environmentVariables' => array(
             'assetsUrl' => 'http://test.example.com/shop/assets/',
             'assetsBasePath' => '/home/example/public_html/shop/assets/',
             'siteUrl'  => 'http://test.example.com/',
         )
     ),
);
5

The siteUrl config setting is not meant to be added under environmentVariables.

'test.dev' => array(
    'siteUrl' => 'http://test.dev/',
    'environmentVariables' => array(
        // ...
    ),
    // ...
)
2

This seems to solve the problem:

define('SERVER_NAME', $_SERVER['SERVER_NAME']);
 if (!isset($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") {
     define('SITE_URL', "http://".SERVER_NAME . '/');
 } else {
     define('SITE_URL', "https://".SERVER_NAME . '/');
 }

 return array(
     '*' => array(
         'siteUrl' => SITE_URL,
     ),

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.