Hack 40 Secrets of Web Site Hosting with Internet Information Services (IIS)


XP Professional includes a free, built-in web server. If you're planning on using it, check out these tips to improve your site's performance, cut down on bandwidth, deliver pages faster, and reduce Page Not Found errors.

If you've wanted to host a web server but don't want to go to the trouble of configuring a separate machine and server, XP Professional has help for you. Windows XP Professional comes with Internet Information Services (IIS) Version 5.1, which lets you host web sites and FTP sites and run a Simple Mail Transfer Protocol (SMTP) service for sending email. (The Home Edition doesn't include any of these capabilities.) It's not something you'll use to build a substantial web site, because it has some significant drawbacks. The web server and FTP server allow only 10 simultaneous connections, for example, and the SMTP server isn't a full-blown mail server; it can only act as a relay.

Still, if you want to host a small web site for friends, family, or only for internal use for a small business, or if you want to build a "staging server" to test out sites before publicly posting them on a different server, IIS is a good bet.

IS isn't installed by default in XP Professional. To install it, choose Control Panel Add or Remove Programs Add/Remove Windows Components and, from the Windows Component Wizard that appears, highlight Internet Information Services (IIS) and click on Details.

Administer your web site by using the Microsoft Management Console (MMC) IIS snap-in. Choose Control Panel Administrative Tools and double-click on Internet Information Services. The console tree, shown in Figure 4-11, shows the structure of your web and FTP sites and also gives you control over those sites.

Figure 4-11. The console tree for the MMC IIS snap-in

In this hack, I'll assume that you know the basics of building a web site with IIS, so I'll instead clue you in to secrets of IIS.

4.9.1 Change the Directory and Do a Redirect

By default, IIS uses the C:\Inetpub\wwwroot directory for your web site. However, you'll most likely want to change that directory to one that better matches your own PC setup. To change it, launch the MMC snap-in as detailed earlier in this hack, then right-click on Default Web Site and choose the Home Directory tab, shown in Figure 4-12. In the Local Path box, type in or browse to the directory you want to use.

Figure 4-12. The Default Web Site Home Directory tab

If you want to use a directory on another computer located on the network, select "A share located on another computer." The Local Path box changes to Network Directory, and the Browse button changes to a Connect As button. Type in the directory information from the other computer, then click on Connect As to use your logon credentials to use the network share.

This tab also lets you do a redirect of your web site so that when someone visits your web site they'll be redirected to another site. That site doesn't have to be on your network; it can be any location on the Internet. This option is most useful when you move your web site to another URL but want those who use the old URL to be able to access it. To do a redirect, select "A redirection to a URL." The screen will change to the screen shown in Figure 4-13.

Figure 4-13. Redirecting to a URL

You have three options for your redirect:

The exact URL entered above

This redirects all traffic to the URL you specified.

A directory below this one

This lets you force a redirect of a parent directory to a child directory. For example, if someone were to type www.mysite.com in their browser, and you wanted them to end up at www.mysite.com/pics, you'd choose this option and have the location www.mysite.com/pics in the "Redirect to" box.

A permanent redirection for this resource

When this option is chosen, a " 301 Permanent Redirect" message will be sent to the visiting browser. This can be used by some browsers to automatically update their bookmarks or Favorites list with your new site location.

4.9.2 Redirect Incorrect Incoming URLs

They're the bugaboo of every web site administrator?people who mistype URLs and get the dreaded "404 The page cannot be found" error. For example, if someone wanted to visit http://www.gralla.com/mybio.htm, but instead typed http://www.gralla.com/myboi.htm into their browser, they'd get an error message. And I'd lose a visitor.

Solve the problem with URLSpellCheck for IIS (http://www.port80software.com/products/urlspellcheck/). It redirects misspelled URLs to the right page, so that your visitors don't get error messages. It fixes instances in which an extra character is put into the URL, characters are transposed, a character is missing, or the wrong character is typed. It will also fix instances when the incorrect extension is typed.

URLSpellCheck can't fix problems when someone types in the wrong domain?for example, http://www.grala.com rather than http://www.gralla.com. Domains are handled by the Domain Name System (DNS), so add-in software can't solve the problem. To solve it, you'd have to own the various misspellings of your domain and then have DNS redirect them to the proper domain.

The program runs as a snap-in to the MMC. Highlight your web site in the MMC, right-click on the Properties button, and click on the URLSpellCheck tab. From there, you'll be able to enable or disable the program.

URLSpellCheck is shareware and free to try, but if you use it for more than 30 days you're expected to pay $49.95.

4.9.3 Use Caching for Better Performance

When you run a web site, three issues top your list of concerns: how to preserve bandwidth, how to reduce the performance load on your PC, and how to make the site load faster for visitors.

Here's a three-for-one solution: use caching properly. When visitors come to your site, have them use cached images such as logos, navigation bars, and similar content from their own PC, rather than hitting your server every time. When you do this, after they retrieve the image for the first time, each subsequent time they need to get the image, it's retrieved from their own PC, rather than your server. Their pages load faster, your PC doesn't have to serve up as much content, and you don't use as much bandwidth.

To make sure your site uses caching, try CacheRight (http://www.port80software.com/products/cacheright/). Like URLSpellCheck, it runs as a snap-in to MMC. To use it, highlight your web site in MMC, right-click on the Properties button, and click on the CachRight tab. From there, you'll be able to enable or disable the program, as well as set options for how the cache should be used. The main option you'll set is expiration policies for the cache?in other words, at what point the visiting browser should check your web site to see whether the content the browser has cached is old and needs to be updated. You set the amount of time, such as a week, and set when that time should start, either the last time the browser visited your site or the last time you modified the cached content. I prefer to use the start time as the last time I modified the cached content; that way, browsers won't unnecessarily try to get content from my site.

CacheRight is shareware and free to try, but if you use it for more than 30 days you're expected to pay $149.95.

4.9.4 See Also

  • The IISFAQ site (http://www.iisfaq.com) is a great source for tips, advice, and downloads related to IIS.