I had one normal config.php file. This had nothing in it except to find the hostname from the SERVER variable or the address the user is trying to get to (which moodle they are trying to get to).
e.g. if you are going to http://moodlelocal or moodle2local or moodle3local etc then this would be the hostname
I then had a config file for every single one of these. e.g.
This config is the normal config file with the dbhost, wwwroot, dataroot etc etc.
Each one of the moodle2local etc had its own config file. Each pointed to a different database and each pointed to a different datafolder but all pointed wwwroot to the same folder.
The central config.php gets the host name and then does an include/requires by concatenating the hostname and '.config.php' to get the correct config (with CFG->dbhost, CFG->dataroot) in it etc. This then loads the correct config up and Moodle is non the wiser. (Dont forget the pathname if your new configs dont appear next to your original config.php file). So basically, config.php has three lines, unset($CFG), $hostname=$_Server['hostname'] (doing this from memory so please dont hold me on it!) and include_once($hostname.'.config.php');
On a linux server all I did was alter the apache httpd config file to have a virtual host for each web address. e.g. moodledev2.domain.ac.uk, moodledev3.domain.ac.uk, moodledevanothername.domain.ac.uk. The new configs then became moodledev2.domain.ac.uk.config.php etc etc, there was still of course the normal config.php file. Then there were ipaddresses mapped to these dns entries by the network team.
On a windows local host I did the same, but, to get windows to understand moodle2local etc etc, rather than localhost/moodle i had to change the windows hosts file and add them in there (i cant recall the exact path of the hosts file). Each host then pointed to 127.0.0.1 (localhost). I then altered the httpd file for the xampp installation i had to all point to the c:/xampp/htdocs/moodle folder where the ONE set of code I had installed was sat (this was managed by GIT, but thats a side/extra thing from this process).
I dont have the files to hand right this minute otherwise I would send them, and I am saying all of this off of the top of my head right this minute.
Hope it helps.