In my view It gets the server URL from the setting in Deployment Manager and you can change it from there. I am copying links to some articles for your perusal:
mscrmshop.blogspot.com/.../step-by-step-tutorial-to-add-entity-url.html
stackoverflow.com/.../how-to-insert-record-url-into-email-template