Environment specific siteUrl settings not working I followed the advice from this and this post, but I just can't get my environment specific siteUrls to work.
This is what my config file looks like:
return array(

    '*' =&gt; array(
      'errorTemplatePrefix' =&gt; &quot;pages/&quot;,
    ),

    '.dev' =&gt; array(
      'environmentVariables' =&gt; array(
        'userSessionDuration' =&gt; false,
        'devMode' =&gt; true,
        'siteUrl ' =&gt; 'http://myurl.dev',
      )
    ),

    '.com' =&gt; array(
      'environmentVariables' =&gt; array(
        'userSessionDuration' =&gt; false,
        'devMode' =&gt; true,
        'siteUrl ' =&gt; 'http://myurl.com',
      )
    ),

    '.org' =&gt; array(
      'environmentVariables' =&gt; array(
        'siteUrl'  =&gt; 'http://myurl.org',
      )
    )
);

These do not take precedence over any URL specified in Settings &gt; General in the CP as outlined in the docs. If I set the Site URL field to {siteUrl} in the CP, then my links are broken and look like this: {siteUrl}/link-to-a-page.
Am I missing something else to get the siteUrl settings to work?

Update
Fixed the additional space in 'siteUrl ', thanks to Lindsey.
My config settings now look like this:
'*' =&gt; array(
  'errorTemplatePrefix' =&gt; &quot;pages/&quot;,
),
// local
'.dev' =&gt; array(
  'devMode' =&gt; true,
  'userSessionDuration' =&gt; false,
  'environmentVariables' =&gt; array(
    'siteUrl' =&gt; 'http://myurl.dev',
  )
),
// staging
'.com' =&gt; array(
  'devMode' =&gt; true,
  'userSessionDuration' =&gt; false,
  'environmentVariables' =&gt; array(
    'siteUrl' =&gt; 'http://myurl.com',
  )
),
// live
'.org' =&gt; array(
  'environmentVariables' =&gt; array(
    'siteUrl'  =&gt; 'http://myurl.org',
  )
)  

With this and adding {siteUrl} in the CP, everything works as expected - hooray!
It does however not reflect what the Craft docs say, as they state that the config settings &quot;will take precedence over the Site URL setting in Settings → General&quot;. I've contacted the Craft team to let them know about this.

Update #2
Got this response from Brandon:

“I'm guessing that when you added 'siteUrl' to your config, you put it inside the environmentVariables array? (which would explain why adding {siteUrl} to the CP setting made it work.)
When the documentation is referring to the siteUrl config setting, it's referring to an actual top-level config setting, not some custom &quot;siteUrl&quot; environmentVariable that happens to have the same name.”

So I've taken the setting out of environmentVariables, and hey presto, it all works as expected. You even get a helpful message in the CP:

Final working code:
'*' =&gt; array(
  'errorTemplatePrefix' =&gt; &quot;pages/&quot;,
),
// local
'.dev' =&gt; array(
  'devMode' =&gt; true,
  'userSessionDuration' =&gt; false,
  'siteUrl' =&gt; 'http://myurl.dev',
),
// staging
'.com' =&gt; array(
  'devMode' =&gt; true,
  'userSessionDuration' =&gt; false,
  'siteUrl' =&gt; 'http://myurl.com',
),
// live
'.org' =&gt; array(
  'siteUrl'  =&gt; 'http://myurl.org',
)

Got there in the end - phew!
Make sure that you change .dev, .com, etc. to reflect your actual environment URLs. They operate based on a partial string match, so as long as your URL contains one of those substrings, it'll pick up the first one it matches.

For example:

'local.mywebsite' =&gt; array(
  'environmentVariables' =&gt; array(
    'userSessionDuration' =&gt; false,
    'devMode' =&gt; true,
    'siteUrl ' =&gt; 'http://local.mywebsite',
  )
),

'mywebsite.com' =&gt; array(
  'environmentVariables' =&gt; array(
    'userSessionDuration' =&gt; false,
    'devMode' =&gt; true,
    'siteUrl ' =&gt; 'http://mywebsite.com',
  )
),




UPDATE

Whoa, I think I may have just realized what the problem is... I copied my example from your original code, and copied a glitch right along with it...

You've listed siteUrl like this:

    'siteUrl ' =&gt; 'http://mywebsite.com'


Notice anything? There is an extra space between siteUrl and the closing quote.

    'siteUrl '


... should be:

    'siteUrl'