How to setup hostname to website in local IIS
If you want to do this locally then modifying the HOSTS file of the server hosting your site to point to the local machine's IP when visiting the abcd.com domain should do it.
Modifying your hosts file allows you to override the DNS for a domain, on that particular machine. This is useful when you want to test your site without the test link, prior to going live with SSL; verify that an alias site works, prior to DNS changes; and for other DNS-related reasons. Modifying your hosts file causes your local machine only to look directly at the IP address specified.
- Press the Windows key.
- Type Notepad in the search field.
- In the search results, right-click Notepad and select Run as administrator.
- In Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts
-
Add the following entry to the file:
Local IP Address www.abcd.com
Click File > Save to save your changes.
Source: http://www.rackspace.com/knowledge_center/article/modify-your-hosts-file
NOTE: If you want to do this from another computer you have admin rights on then you use the same approach. If you want to do this from another computer you do not have admin rights on then you should go about getting a dedicated DNS entry set up for this site
GB Patil
I'm a web developer. I code for smaller websites to large-scale web-based applications. I love core javascript, HTML and ASP. I like to make web apps easy and intuitive for the user.
Updated on July 09, 2022Comments
-
GB Patil almost 2 years
I am using Windows 10 with IIS enabled.
I need to setup local websites on different ports with hostnames which I can access locally by using those hostnames.For e.g.
Website Name: abcd website
Path to Directory: D:/Projects/Websites/abcd.com
Hostname: abcd.com
Port: 1001Currently I can access the website with localhost:1001 or 127.0.0.1:1001 But I'm looking forward that my local websites should get resolved with hostnames. So, if I go to http://abcd.com/ it should take me to http://localhost:1001/
With this I wish to setup subdomains to some websites as well. I need help to achieve this.
-
GB Patil over 8 yearsHi @ShaneC, I have tried this but still when i type in abcd.com it redirects to the website hosted with that domain on the web. But note that when i ping for the hostname www.abcd.com it shows that "Reply from IP_Address". IP address here shown is the one I entered in hosts file. Also, basically what i want is test.localhost.com should bind with 127.0.0.1:1001 and prod.localhost.com should bind with 127.0.0.1:1002. I have seen this happening in my old company environment where i used to work. They must be having some static IP but i keen to know can we do this on localhost.
-
ShaneC over 8 yearsStrange, the HOSTS file has priority over resolution by DNS servers (support.microsoft.com/en-us/kb/172218). This might be beyond my knowledge I'm afraid, I've never bound port numbers to IP addresses, not with the HOSTS file (see stackoverflow.com/questions/8652948/…), user01's answer on that question regarding Fiddler2 may be an option for you