@ both ...
config.php file is one (for sure), but remember that Moodle is backended by a data base which contains links to files and images built from the wwwroot variable in the config.php file.
Do a complete site backup before using the following:
Neither has mentioned version of Moodle running, so the following may not apply:
change config.php file appropriately.
Then use the replace.php script to search for 'old site' replace with 'newsite' in the DB ...
comment in replace.php for 1.9.19:
Search and replace strings throughout all texts in the whole database
version 1.9.19+ it's found in admin/replace.php
version 2.x it's found /admin/tool/replace/
Search for full URL: 'http://oldsite/subdir/'
Replace with full URL: 'http://newsite/subdir/'
include the 'trailing slash'.
Again: make a site backup ... especially the DB. If the search and replace is not done correctly, the easiest way to get the site back to functioning state is to drop the database and import the .sql dump from the backup.
'spirit of sharing', Ken