<p>The <code>siteUrl</code> config setting is not meant to be added under <code>environmentVariables</code>.</p>

<pre class="lang-php prettyprint-override"><code>'test.dev' =&gt; array(
    'siteUrl' =&gt; 'http://test.dev/',
    'environmentVariables' =&gt; array(
        // ...
    ),
    // ...
)
</code></pre>

CC BY-SA 3.0
2016-07-05T11:11:33.777Z
2016-07-05T11:11:33.777Z
carlcs
<p>This seems to solve the problem: </p>

<pre><code>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(
     '*' =&gt; array(
         'siteUrl' =&gt; SITE_URL,
     ),
</code></pre>

CC BY-SA 3.0
2016-07-05T11:13:11.113Z
2016-07-05T11:13:11.113Z
Dan Lee
<p>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.</p>

<p>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?</p>

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

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

<siteurl>
siteUrl config and Control Panel conflict
# siteUrl config and Control Panel conflict

(Asked by: username_0 on 2016-07-05)

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/',
         )
     ),
);

**Tags:** siteurl


---

## 2 answers

### Answer by username_1 on 2016-07-05. Score: 5

The siteUrl config setting is not meant to be added under environmentVariables.
'test.dev' => array(
    'siteUrl' => 'http://test.dev/',
    'environmentVariables' => array(
        // ...
    ),
    // ...
)


---

### Answer by username_0 on 2016-07-05. Score: 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,
     ),


---

