Microsoft KB Archive/930909

From BetaArchive Wiki

Article ID: 930909

Article Last Modified on 1/23/2007



APPLIES TO

  • Microsoft Internet Information Services 7.0



INTRODUCTION

The following features cannot be configured by using the Microsoft Internet Information Services (IIS) 7.0 Manager:

  • HTTP logging
  • HTTP redirection
  • HTTP response headers
  • HTTP compression

To enable and configure these features, you must use the Appcmd.exe command-line tool instead.

MORE INFORMATION

To enable these features in IIS 7.0, use the Appcmd.exe command-line tool. When you use this tool, you must first enable the feature. Then, you must configure the settings for the feature. When you run the Appcmd.exe tool, settings are updated in the %windir%\System32\Inetsrv\Config\ApplicationHost.config file.

The following sections describe how to use the Appcmd.exe tool to enable various HTTP features in IIS 7.0. To determine other IIS attributes and settings that you can change by using the Appcmd.exe tool, view the full schema in the %windir%\System32\Inetsrv\Config\Schema\IIS_schema.xml file.

HTTP logging

To enable logging for HTTP requests, follow these steps:

  1. Click Start[GRAPHIC: Start button], type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

    [GRAPHIC: User Account Control permission] If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
  2. Type the following command, and then press ENTER:

    cd \windows\system32\inetsrv

  3. Type the following command, and then press ENTER:

    appcmd set config /section:httpLogging /dontLog:False /selectiveLogging:LogAll

    Note This command configures HTTP logging to use the default logging settings from the schema file for all Web sites that are configured on the Web server. The selectiveLogging attribute can equal one of the following values:

    • LogError
      This value specifies that all errors are logged.
    • LogSuccessful
      This value specifies that all successful requests are logged.
    • LogAll
      This value specifies that all requests are logged.

To disable logging for HTTP requests, type the following command, and then press ENTER:

appcmd set config /section:httpLogging /dontLog:True


Additional logging options

After you have enabled logging for HTTP requests, you can set additional logging options. For example, you can set specific information to log. The following command demonstrates how to log only HTTP substatus information for all Web sites:

appcmd set config /section:sites -siteDefaults.logFile.logExtFileFlags:HttpSubStatus


You can log the following information for the Web site that has an ID value of 1:

  • HTTP substatus
  • Host
  • Time
  • Date

To do this, use a command that resembles the following:

appcmd set config /section:sites /[id='1'].logFile.logExtFileFlags:HttpSubStatus,Host,Time,Date


HTTP redirection

To enable HTTP redirection, follow these steps:

  1. Click Start[GRAPHIC: Start button], type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

    [GRAPHIC: User Account Control permission] If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
  2. Type the following command, and then press ENTER:

    cd \windows\system32\inetsrv

  3. Type the following command, and then press ENTER:

    appcmd set config /section:httpRedirect /enabled:true

To add an HTTP redirection rule, type the following command, and then press ENTER:

appcmd set config /section:httpRedirect/+[wildcard='WildcardHeader',destination='Destination']


Note In this command, WildcardHeader represents the Web page or pages that you want to redirect. Destination represents the destination Web page to which the WildcardHeader value redirects.

To disable HTTP redirection, type the following command, and then press ENTER:

appcmd set config /section:httpRedirect /enabled:false


HTTP response headers

To add an HTTP response header, follow these steps:

  1. Click Start[GRAPHIC: Start button], type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

    [GRAPHIC: User Account Control permission] If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
  2. Type the following command, and then press ENTER:

    cd \windows\system32\inetsrv

  3. Type the following command, and then press ENTER:

    appcmd set config /section:httpProtocol /+customHeaders.[name='HeaderName',value='HeaderValue']

    Note In this command, HeaderName represents the name of the HTTP header that you are adding. HeaderValue represents the value of the HTTP header that you are adding.

To edit an HTTP response header, type the following command, and then press ENTER:

appcmd set config /section:httpProtocol /customHeaders.[name='HeaderName']. value:HeaderValue


Note In this command, HeaderName represents the name of the HTTP header that you want to edit. HeaderValue represents the value of the HTTP header that you are editing.

To view a list of HTTP response headers, type the following command, and then press ENTER:

appcmd list config /section:httpProtocol


HTTP compression

To enable HTTP compression, follow these steps:

  1. Click Start[GRAPHIC: Start button], type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.

    [GRAPHIC: User Account Control permission] If you are prompted for an administrator password or for confirmation, type your password, or click Continue.
  2. Type the following command, and then press ENTER:

    cd \windows\system32\inetsrv

  3. Enable static content compression or dynamic content compression. To do this, use one of the following methods:
    • To enable static content compression, type the following command, and then press ENTER:

      appcmd set config /section:urlCompression /doStaticCompression:True

    • To enable dynamic content compression, type the following command, and then press ENTER:

      appcmd set config /section:urlCompression /doDynamicCompression:True


REFERENCES

For more information about the Appcmd.exe tool, visit the following Microsoft Web site:

For more information about how to configure HTTP logging in IIS 7.0, visit the following Microsoft Web site:

For more information about how to edit a redirect rule in IIS 7.0, visit the following Microsoft Web site:

For more information about how to configure HTTP response headers in IIS 7.0, visit the following Microsoft Web site:

For more information about how to configure HTTP compression in IIS 7.0, visit the following Microsoft Web site:

Keywords: kbhowto kbinfo KB930909