A bit more detail:
lets say I have the following domains that I do not have DNS control over (they are just public websites)
www.example.com sub.example.com
If there is a way, how could I get my computer to automatically forward me to sub.example.com when I accidentally forget and type www.example.com?
I was thinking that I might be able to use the hosts file and Apache, and do a redirect there, but does anyone have any other suggestions?
My example:
Hosts file:
127.0.0.1 www.example.com
Apache configuration (or .htaccess file):
RewriteCond %{HTTP_HOST} ^www\.example\.com$
RewriteRule ^$ http://sub.example.com/? [L,R=301]
Would this work, if so, is this the best way to do this, or is there a better way?