I'm doing an integration that involves passing fully qualified URLs to another application as form inputs so that they can be used for a callback. The URL is for another Visualforce page (not a webservice). For example, a form might look something like this:

```
<form action="https://myformaction">
    <input type="hidden" name="callbackUrl" value="URL-GOES-HERE"/>
    <!-- rest of the form -->
</form>

```

I'm having trouble getting a valid, fully qualified URL to show up. Here's what I've tried:

1. `{!URLFOR($Page.PageName)}` ==> `/siteprefix/PageName`, which doesn't work because it's a relative URL, so the external service can't redirect to it.
2. `{!$Site.CurrentSiteUrl}{!URLFOR($Page.PageName)}` ==> `https://salesforce.domain/siteprefix//siteprefix/PageName`, which doesn't work because the siteprefix is included twice, and there's a double `//`
3. `https://{!$Site.Domain}{!URLFOR($Page.PageName)}` ==> `https://salesforce.domain/siteprefix/PageName`, which works for now - but I'm worried it will break when we switch to a custom domain down the line.

I've run into the same problem when trying to include links in Visualforce email templates, where the `$Site` variable isn't available. Am I missing something? Seems like this should be a simple thing to do...