How can I use multi-environment configuration to set each root URL? I'm building www.mynewcraftsite.com.au, but I also wanna create www.mynewcraftsite.dev which is a testing server to preview to my clients. I've heard that I can set this up with Craft without going through the drudgery of downloading/uploading databases and updating urls in the db, users ... etc.

I've been reading the Craft CMS documentation for "Multi-Environment Configs".  So far I've got this in my db.php file;

return array(
    //All environments
    '*' =&gt; array(
        'omitScriptNameInUrls' =&gt; true,
        'localhost' or '127.0.0.1'.
        'server' =&gt; 'localhost',
        'user' =&gt; 'dashing-print',
        'password' =&gt; 'f#$njEwFRn3&amp;2',
        'database' =&gt; 'dashing-print',
        'tablePrefix' =&gt; 'craft'
    ),

    //Testing environment
    'www.mynewcraftsite.dev' =&gt; array(
        'siteUrl' =&gt; 'www.dashingprint.dev'
    ),

    //Live environment
    'www.mynewcraftsite.com.au' =&gt; array(
        'siteUrl' =&gt; 'www.dashingprint.com.au'
    )
);


It works EXCEPT when I go to www.mynewcraftsite.dev and then click on the links, I end up back on www.mynewcraftsite.com.au (eg. Instead of going to www.mynewcraftsite.dev/services, I go to www.mynewcraftsite.com.au/services. In order to get to the correct page I gotta write up the whole url www.mynewcraftsite.dev/service into the google chrome url bar.)

The siteURL property isn't doing anything, there's gotta be something else that I gotta stick in there in order to rewrite the urls.
Make sure to change the "Site URL" setting to {siteUrl} in your control panel settings...


  Control Panel > Settings > General > "Site URL"


Within your config file, you'll also want to put your siteUrl value inside of an Environment-Specific Variables sub-array:

'mynewcraftsite.dev' =&gt; array(
    'devMode' =&gt; true,
    'environmentVariables' =&gt; array(
        'siteUrl' =&gt; 'http://www.mynewcraftsite.dev/'
    )
),
'mynewcraftsite.com.au' =&gt; array(
    'environmentVariables' =&gt; array(
        'siteUrl' =&gt; 'http://www.mynewcraftsite.com.au/'
    )
)




Here's how Craft is compiling all of that... 

Within each of your environment configurations, there are many config settings that you can apply to that specific environment. Additionally, each environment can have a sub-array called environmentVariables, which allows you to set whatever unique variables you want. The most common examples are siteUrl and fileSystemPath (great for setting up assets sources), but you can truly set whatever environment variables you want.

Once you've set the siteUrl value in your environment variables array, you now need to use that value... This is where the control panel settings page comes into play. Changing "Site URL" to simply {siteUrl} tells Craft to pull that value from your environment variables.

IMPORTANT: Notice the single set of curly braces, and the lack of spacing between the variable name and the braces. This is the syntax difference between environment variables and Twig variables.

That's it! When you create a path, Craft will use whatever is in the "Site URL" setting. And since that's pulling in your environment variable, that's what you'll get.



Lastly, allow me to point out a few things in your example which may also be stopping this from working for you (feel free to update the example in your question to fix these issues)...

Most importantly: You're combining data that should be stored in two separate files... craft/config/db.php and craft/config/general.php. While the multi-environment format is the same, you'll need to separate the data shown in your example. Put most of your settings into general.php, only the following belong in db.php:


server
user
password
database
tablePrefix


You also have an errant line of code in your example... This line should definitely be removed:

'localhost' or '127.0.0.1'.


Finally, you've left some crucial security information in your example... All of your database connection info is exposed (as well as your true domain names in your siteUrl examples).



Hope that helps... If you fix the bugs in your example code, I'll remove my corresponding notes from this answer. :)