Reputation: 780
I'm having few applications under DefaultWebSite on IIS pointed to the same source code and distinguished by aliases:
localhost/app1
localhost/app2
localhost/app3
Is it possible to configure different hostnames for each app via windows hosts file? For example, to have them like this:
app1.localhost
app2.localhost
app3.localhost
I needed it to test a single sign-on feature and to be sure that auth cookie isn't shared inside the same domain(localhost)
Upvotes: 0
Views: 217
Reputation: 27997
In my opinion, you should modify the hosts file and url rewrite rule to achieve your requirement.
Firstly ,you should go to the hosts file(C:\Windows\System32\drivers\etc) and add below settings.
127.0.0.1 app1.localhost
127.0.0.1 app2.localhost
127.0.0.1 app3.localhost
Then you could add below url rewrite rule into the web.config to rewrite appx.localhost to localhost/app1.
<rule name="cio">
<match url="(.*)" />
<conditions>
<add input="{HTTP_HOST}" pattern="^(.*).localhost" />
</conditions>
<action type="Rewrite" url="http://localhost/{C:1}/{R:0}" />
</rule>
Upvotes: 1