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:
- Click Start, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.
If you are prompted for an administrator password or for confirmation, type your password, or click Continue. - Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
- 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.
- LogError
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:
- Click Start, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.
If you are prompted for an administrator password or for confirmation, type your password, or click Continue. - Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
- 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:
- Click Start, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.
If you are prompted for an administrator password or for confirmation, type your password, or click Continue. - Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
- Type the following command, and then press ENTER:
appcmd set config /section:httpProtocol /+customHeaders.[name='
HeaderName
',value='HeaderValue
']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:
- Click Start, type command prompt in the Start Search box, right-click Command Prompt in the Programs list, and then click Run as administrator.
If you are prompted for an administrator password or for confirmation, type your password, or click Continue. - Type the following command, and then press ENTER:
cd \windows\system32\inetsrv
- 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
- To enable static content compression, type the following command, and then press ENTER:
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:
http://technet2.microsoft.com/WindowsServer/en/library/bcb7fbfa-8f61-42ca-88ca-59123be5f0011033.mspx
For more information about how to edit a redirect rule in IIS 7.0, visit the following Microsoft Web site:
http://technet2.microsoft.com/WindowsServer/en/library/cf7b4288-0157-4a0c-883a-bb9b8afaff271033.mspx
For more information about how to configure HTTP response headers in IIS 7.0, visit the following Microsoft Web site:
http://technet2.microsoft.com/WindowsServer/en/library/37283911-0b7f-40ef-9cad-7ba05425e7e71033.mspx
For more information about how to configure HTTP compression in IIS 7.0, visit the following Microsoft Web site:
Keywords: kbhowto kbinfo KB930909