Map the User Friendly Host Name With Its Corresponding IP Address
In this article, the author is going to cover how to map the user-friendly host name with its corresponding IP address using Host File in IIS.
Join the DZone community and get the full member experience.Join For Free
in this article, i am going to cover how to map the user-friendly host name with its corresponding ip address using host file in iis.
a few days back i got a requirement to change the ip address of our locally hosted website in iis 8 of windows server 2012 r2, since it was difficult for the client to remember the ip address every time.
screen shot of expected output before changing host file
now i am going to change this to some user-friendly name, for ex : www.karthiksachin.com
let's see step by step how can we achieve this.
brief intro about host file
what is host file?
in simple words, host file is like a telephone directory which will contain the number(ip address) and associated address(host name). so when you give a host name like www.google.com into your browser, then the host file is started to see if you have the ip address for that site. if you have, then your computer will get it and act accordingly, otherwise, it will ask the details to the isp.
location of host file in file system
the path to the host file in windows is %systemroot%\system32\drivers\etc\ where %systemroot% is usually c:\windows unless you installed windows on a different partition. so the same can be written as c:\windows\system32\drivers\etc\hosts.
step 1 - to access the host file in windows 7 you can use the following command in the run line to open notepad and the file.
then it will open the following text file as shown below,
then it will open the default file like below:
original file before changing how it looks:
after changing the file as per requirement:
note: make sure you have taken the # symbol from that line because it denotes comment.
that's it from the host file point of view.
now just change following in the iis, like the screenshots below:
tried the same in window server 2012 r2:
i hope the above information was a little bit helpful. kindly share your valuable comments or feedback.
Opinions expressed by DZone contributors are their own.