If you change
to $site->url(), you may get what you want or need.
I don’t know you webserver configuration, but on my “XAMPP on Windows server” and the respective live linux server this runs.
If you want to know why I can suggest this here, you can look at the “gear wheel” links at HowTo: Working with contextual links to the panel, where I have used this.
Good luck!