Set-IisHttpRedirect

Turns on HTTP redirect for all or part of a website.

Syntax

Set-IisHttpRedirect [-SiteName] <String> [[-Path] <String>] [-Destination] <String> [[-StatusCode] <String>] [-ExactDestination] [-ChildOnly] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

Configures all or part of a website to redirect all requests to another website/URL. By default, it operates on a specific website. To configure a directory under a website, set Path to the virtual path of that directory.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
SiteName String The site where the redirection should be setup. true false
Path String The optional path where redirection should be setup. false false
Destination String The destination to redirect to. true false
StatusCode String The HTTP status code to use. Default is Found. Should be one of Found (HTTP 302), Permanent (HTTP 301), or Temporary (HTTP 307). false false
ExactDestination SwitchParameter Redirect all requests to exact destination (instead of relative to destination). I have no idea what this means. Maybe TechNet can help. false false
ChildOnly SwitchParameter Only redirect requests to content in site and/or path, but nothing below it. I have no idea what this means. Maybe TechNet can help. false false
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.

EXAMPLE 1

Set-IisHttpRedirect -SiteName Peanuts -Destination 'http://new.peanuts.com'

Redirects all requests to the Peanuts website to http://new.peanuts.com.

EXAMPLE 2

Set-IisHttpRedirect -SiteName Peanuts -Path Snoopy/DogHouse -Destination 'http://new.peanuts.com'

Redirects all requests to the /Snoopy/DogHouse path on the Peanuts website to http://new.peanuts.com.

EXAMPLE 3

Set-IisHttpRedirect -SiteName Peanuts -Destination 'http://new.peanuts.com' -StatusCode 'Temporary'

Redirects all requests to the Peanuts website to http://new.peanuts.com with a temporary HTTP status code. You can also specify Found (HTTP 302), or Permanent (HTTP 301).