Multiple localhost:80-bound sites in IIS?

前端 未结 1 1879
抹茶落季
抹茶落季 2021-02-13 14:12

(You can skip directly to the question, but the context is on the background section.)

Technical Context

  • Windows 8
  • IIS 7
相关标签:
1条回答
  • 2021-02-13 14:26

    Your hosts file needs to match your IIS bindings, which have to match the url browser.

    So if your hosts file looks like:

    127.0.0.1 siteA.localhost
    127.0.0.1 siteB.localhost
    

    Your IIS bindings need to be:

    site    host header       port
    siteA   siteA.localhost   80
    siteB   siteB.localhost   80
    

    Finally, from the local machine, you need to browse to:

    http://siteA.localhost
    

    EDIT - If you are trying to do the above without adding the hosts entries for siteA and siteB, it won't work. DNS won't find it. So for example, what happens if you try to browse to "foo.stackoverflow.com" - the request will fail even though "stackoverflow.com" is a known address.

    0 讨论(0)
提交回复
热议问题