For a while, I found my self doing something like this:
pageReference pageRef = new pageReference('https://na4.salesforce.com/apex/mypagename');
Obviously, those links would break when pushed from a sandbox to production and I would have to modify the code.
To save time, I came up with this to prevent those changes:
String hostname = ApexPages.currentPage().getHeaders().get('Host');
pageReference pageRef = new pageReference ('https://'+hostname +'/yourpagenamehere’);
system.debug('pageRef was: ';+ pageref);
return pageRef;