In ASP.NET, the tilde (~) is treated as a token in URLs and treats paths prefixed with that as relative to the application root. This is well-known functionality.
In MOSS, there are other tokens, such as ~sitecollection/mypath… which behaves in a similar way, but treats the path as relative to the site collection root. How is this accomplished? After a cursory search I could not find any info on how to add tokens like this to the .NET URL resolution mechanism.
Best Answer
It may not be the only place, but SPUtility.GetServerRelativeUrlFromPrefixedUrl() will parse URLs with ~site and ~sitecollection. MOSS also provides SPUrlExpressionBuilder for declarative use: