How do I - Change a SharePoint site URL?

This is probably one of the most common questions I've been asked over the years.  Unfortunately, Microsoft doesn't provide a UI method for users to change the URL of their site.  Given the database schema and the relationships between objects and the URL, I've always been perplexed as to why this was never done.  To me it seemed like a pretty easy SQL update.

Although there are many methods to overcome this problem, such as the site backup/restore method described by Todd Klindt, these methods become increasingly more time consuming as the site size grows.  The easiest method in my mind still remains using the SPSite.Rename() method.  Unfortunately, the MSDN article states at the top that it "Changes the URL of a host-header-named site collection to a new URL.".  I believe this is why this method has remained obscure and under-leveraged.  At the end of the article, it also states "After the site rename, an app pool recycle is recommended to force refreshing the cache." which is incorrect.  An app pool recycle is required in order for the new URL to work correctly.

But enough picking apart MSDN articles... let's get to the good stuff. :-)
The following Powershell script does what we want:

The core of the script is lines 9 and 10.
Remember to recycle your web app's app pool!