I would like to list steps of how to migrate of give new URL to existing Moodle site when new URL is purchased or URL change are needed.
DNS record
First, make it sure if new URL is pointing to the server where Moodle is serviced. You can look up how domain name is resolved by nslookup in CLI.
%nslookup moodle.yoursite.com
Update config.php
You can find config.php from Moodle root directory and change the value of
$CFG->wwwroot to the new URL.
$CFG->wwwroot = 'https://moodle.yoursite.ca';
Use Search and Replace tool
Navigate to https://youroldsite.com/admin/tool/replace/ and use search and replace tool to replace old site URL to new one. It does not 100% guaranteed, but it worked for me.

Replace for any details
It is possible for you to see any links to images or icons are broken. When you see their URL it might be pointing out to the old site URL. You can use the tool above to replace those URLs. You have to be specific about your search and replace to include the whole links. Otherwise, it will replace too widely, that can cause malfunctioning of Moodle site.