Configure the Status Code for Redirection (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
Select a status code to specify how a Web browser issues a new request at a different location. Setting a status code lets you customize the redirection process.
For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see HTTP Redirection Feature Requirements (IIS 7).
Exceptions to feature requirements
To configure the redirection status code
You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing the configuration files directly, or by writing WMI scripts.
To use the UI
Open IIS Manager and navigate to the level you want to manage. For information about opening IIS Manager, see Open IIS Manager (IIS 7). For information about navigating to locations in the UI based on your IIS administrative role, see Navigation in IIS Manager (IIS 7).
In Features View, double-click HTTP Redirect.
On the HTTP Redirect page, under Redirect Behavior, select one of the following values from the Status code list:
Found (302) - to tell the Web client to issue a new request to the location specified in the Location HTTP header.
Permanent (301) - to tell the Web client that the location for the requested resource has permanently changed.
Temporary (307) - to tell the Web client to resend the POST data, which prevents a Web browser from losing data when the browser issues an HTTP POST request.
To change the status code, use the following syntax:
appcmd set config /section:httpRedirect /httpResponseStatus: Found|Permanent|Temporary
httpResponseStatus can be one of the following values:
Found: Returns a 302 response code to a client.
Permanent: Returns a 301 response code to a client.
Temporary: Returns a 307 response code to a client.
For example, to change the status code to Permanent, type the following at the command prompt, and then press ENTER:
appcmd set config /section:httpRedirect /httpResponseStatus:Permanent
For information about how to use Appcmd.exe, see Appcmd.exe (IIS 7).
The procedure in this topic affects the following configuration elements:
Use the following WMI classes, methods, or properties to perform this procedure:
- HttpRedirectSection.HttpResponseStatus property
For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.