FYI, the snippet method can be achieved as follows:
Create a snippet called ’getSiteUrl’ and place this inside the snippet:
Now, call the snippet uncached in your base tag:
<base href="[!getSiteUrl!]"></base>
Because the snippet is uncached, it won’t get caught out by the HTTP/1.0 requests causing a blank site URL to be cached. This method will help with sites where you do local development and then transfer to a live server, just one less thing to think about in the transfer process.