15

When I pull up http://localhost in a web browser on my computer (Windows 7, IIS 7.5) I get the IIS 7 welcome image. I have a different website that is set up in IIS that I'd prefer to be the default web site. Can I change that setting somewhere in IIS?

UPDATE: Apparently I have my terminology wrong. What I have is one website (my "Default Web Site") with several applications under it. I have one application that I want to show up when I go to http://localhost instead of the IIS7 welcome image.

I have tried adding a redirect to the default HTML file in C:\inetpub\wwwroot, but that doesn't properly redirect requests for things like scripts and images, though it does redirect the browser.

Mr. Jefferson
  • 697
  • 2
  • 11
  • 25

3 Answers3

15

Turns out you can edit the physical path of the Default Web Site (right click, Manage Web Site, Advanced Settings). Change that to the physical path of the app you want to be default, make sure other settings match (in my case the App Pool had to be changed), and there you go.

Mr. Jefferson
  • 697
  • 2
  • 11
  • 25
8

If you just want a single web site and need to change the folder path for that site then edit the basic settings on the site, changing the physical path to the folder of the other site.

If you mean you've already added a completely new web site in IIS then you need to edit the bindings in your sites.

For web, you'll want to edit the http bindings on both the site labeled Default Web Site and your other desired site. Right-click on the site and choose Edit Bindings... or select the site and click on Bindings... in the Actions pane.

The quickest way is to delete the site labeled Default Web Site, but that might not be the desired thing.

The next quickest way is to change the bindings on the Default Web Site to a different port other than 80. Then set the port on your desired site to 80 and leave the Host Name field blank in the http bindings.

If you want to have both sites running and bound to port 80 then in the bindings on the Default Web Site, put something in the Host name box in the http binding. Leave this empty on your desired site. Keep both on port 80 (or change the default web site to another port). This should now make it so that your desired site is used when someone uses http://localhost or a URL with the hostname of your server.

EDIT:
From your edit - yes, your terminology was a bit off :)

In order to set an app up as the default so that when someone hits the root of your site the app shows up you will have to set up a redirect of some flavor.

Here are a couple of ways to do this:

  • Add an HTTP Redirect to the root level of your web site. Click Default Web Site in the navigation tree and then HTTP Redirect. You'll need to decide for yourself how to configure the redirect based on your needs for the app. This could have lingering effects if you decide to undo this in the future depending on what Status code you set.
  • Add a default page at the root of your web site with a redirect in it (via whatever programming platform you want - HTHML/JavaScript, ASP[.NET], etc). This is probably easiest and quickest and will not necessarily have a lingering affect.
squillman
  • 37,883
  • 12
  • 92
  • 146
  • I think my terminology was wrong. See my edit. – Mr. Jefferson Jul 25 '12 at 19:14
  • @Mr. Jefferson Yep! No problem, see my edit. – squillman Jul 25 '12 at 19:31
  • Your second option seems to be what is suggested [here](http://stackoverflow.com/questions/6949597/setting-the-default-application-in-iis-7), and I tried it but it doesn't work for non-HTML resource requests (scripts, images, etc) – Mr. Jefferson Jul 25 '12 at 19:35
  • Can you clarify your first option? I don't see an option for HTTP Redirect anywhere under Default Web Site. – Mr. Jefferson Jul 25 '12 at 19:37
  • Ah, you're right about the non-HTML resources... Good point. For HTTP Redirect, Click on Default Web Site and look in the center section under IIS. There should be an HTTP Redirect icon. Make sure you're on the Features View tab instead of Content View (at the bottom of the screen). – squillman Jul 25 '12 at 19:41
  • I see HTTP Response Headers, but no HTTP Redirect. I've managed to solve it a bit differently, though; turns out you can modify the physical path of the default web site. – Mr. Jefferson Jul 25 '12 at 19:42
  • Hmm. I have HTTP Redirect right next to HTTP Response Headers. Yes, you could do that as well. That's actually going to be the cleanest thing to do. – squillman Jul 25 '12 at 19:44
  • I've got Handler Mappings and ISAPI Filters to either side of HTTP Response Headers. Must be a setting somewhere. It could also be the fact that I'm actually on IIS 7.5, not 7. My mistake. I'll update the question appropriately. – Mr. Jefferson Jul 25 '12 at 19:46
  • 2
    Ah, I know what's going on. You have to have installed the feature. Go to Control Panel | Programs and Features | Turn Windows Features on or off then under IIS -> WWW Services -> Common HTTP Features you need to select HTTP Redirection. – squillman Jul 25 '12 at 19:51
-1

I found to resolve the issue of looping redirect bug the fix for the root site web.config is:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpRedirect enabled="true" destination="/ApplicationToRedirectTo/" exactDestination="false" childOnly="true" httpResponseStatus="Permanent" />
    </system.webServer>
</configuration>