2

If I set up a website in IIS with a hostname (local.somewebsite.com) (having added it to HOSTS file) and also specify an IP address (127.0.0.1), the website is accessible by the hostname, but hitting it by the IP seems to load the default website and gives a not found message.

Is this expected behaviour? The workaround seems to be pointing the default website back to the folder of the website.

The reason for this question is that we've got a number of websites in a server farm, and one particular action is meant to call the other servers and clear the cache on each of those, so the websites are accessed by both hostname and by IP.

2 Answers 2

2

This is expected behavior.

The most specific combination of bindings is what "takes". If you specify a host header name in the binding then requests must contain the host name (via the HTTP "Host:" header).

If you intend to access a website by IP address then you will need a binding on that site with no host header name specified and the appropriate listening address selected (either "All Unassigned" or a specific IP, depending on how you've assigned other IPs on the machine to sites).

The intent of the host header name feature is to allow you to host multiple sites on the same IP address and port. IIS selects the appropriate site to fulfill incoming requests from based on the HTTP "Host:" header.

0

In IIS you should bind by IP only, the hostname is something you can change from DNS, so you would point the A record "local" for you domain "somewebsite.com" to your IP of choice. Should work.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .