I am using Windows 7 with IIS 7.5. I need to setup local websites on the same IP but on different ports with hostnames which I can access locally by using those hostnames.

For e.g.
Website name: apple website
Path to directory: C:\inetpub\wwwroot\apple
Hostname: applewebsite.com
Port: 44310

Website name: orange website
Path to directory: C:\inetpub\wwwroot\orange
Hostname: orangewebsite.com
Port: 44311

Currently I can access the website with https://localhost:44310 or https://localhost:44311, but I would like that my local websites should get resolved with hostnames: https://applewebsite.com and https://orangewebsite.com

I know that hosts name are stored in C:\Windows\System32\drivers\etc\hosts folder but I know that you can't use ports but only ip-name pairs.

In IIS manager when I try to bind a website, while I change from http protocol to https, the text field "hostname" become grayed. I think that this behavior is due to security certificate but using OpenSSL to create the certificate, the Common Name should be typed as *.websitename.com. In this case while binding the website, the "hostname" field can be edited.

  • Not sure if you've already seen this but check here and the section labeled "Setting Up Host Headers in IIS 7 Using the Command Line". I don't have an IIS server to look at to confirm but as long as you're site binds are correct and you point to the host or host headers, you should be good. Read the top section of that entire post actually it seems to give a good break down and it's worth a try at least and seems simple enough to test with and back out if needed to. – IT Thug Ninja Jul 18 '17 at 17:21
  • I have changed the Common Name in the certificate (called Friendly Name in the guide above) and with initial asterisk I can change the hostname while binding (e.g. www.nameserver.com). Unfortunately when i open the browser and I type the servername inserted previously as hostname, it doesn't reach the site. – Cyr Jul 19 '17 at 12:34

On Windows 7 with IIS 7.5 you can not do this, you need newer versions of Windows.

One way around using ports, is to assign multiple IP addresses to your own machine, map them in your hosts file and then bind the sites to those addresses.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.