Skip to content
v2.278.0

RedirectRuleProperty Struct ​

Specifies how requests are redirected.

In the event of an error, you can specify a different error code to return.

Example ​

ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_s3 as s3 } from 'aws-cdk-lib';
const redirectRuleProperty: s3.CfnBucket.RedirectRuleProperty = {
  hostName: 'hostName',
  httpRedirectCode: 'httpRedirectCode',
  protocol: 'protocol',
  replaceKeyPrefixWith: 'replaceKeyPrefixWith',
  replaceKeyWith: 'replaceKeyWith',
};
python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_s3 as s3

redirect_rule_property = s3.CfnBucket.RedirectRuleProperty(
    host_name="hostName",
    http_redirect_code="httpRedirectCode",
    protocol="protocol",
    replace_key_prefix_with="replaceKeyPrefixWith",
    replace_key_with="replaceKeyWith"
)
java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.s3.*;

RedirectRuleProperty redirectRuleProperty = RedirectRuleProperty.builder()
        .hostName("hostName")
        .httpRedirectCode("httpRedirectCode")
        .protocol("protocol")
        .replaceKeyPrefixWith("replaceKeyPrefixWith")
        .replaceKeyWith("replaceKeyWith")
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.S3;

var redirectRuleProperty = new RedirectRuleProperty {
    HostName = "hostName",
    HttpRedirectCode = "httpRedirectCode",
    Protocol = "protocol",
    ReplaceKeyPrefixWith = "replaceKeyPrefixWith",
    ReplaceKeyWith = "replaceKeyWith"
};
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

redirectRuleProperty := &RedirectRuleProperty{
	HostName: jsii.String("hostName"),
	HttpRedirectCode: jsii.String("httpRedirectCode"),
	Protocol: jsii.String("protocol"),
	ReplaceKeyPrefixWith: jsii.String("replaceKeyPrefixWith"),
	ReplaceKeyWith: jsii.String("replaceKeyWith"),
}

Properties ​

hostNameoptionalstringhost_nameoptionalstrhostNameoptionalStringHostNameoptionalstringHostNameoptional*string #
The host name to use in the redirect request.
httpRedirectCodeoptionalstringhttp_redirect_codeoptionalstrhttpRedirectCodeoptionalStringHttpRedirectCodeoptionalstringHttpRedirectCodeoptional*string #
The HTTP redirect code to use on the response.

Not required if one of the siblings is present.

protocoloptionalstringprotocoloptionalstrprotocoloptionalStringProtocoloptionalstringProtocoloptional*string #
Protocol to use when redirecting requests.

The default is the protocol that is used in the original request.

replaceKeyPrefixWithoptionalstringreplace_key_prefix_withoptionalstrreplaceKeyPrefixWithoptionalStringReplaceKeyPrefixWithoptionalstringReplaceKeyPrefixWithoptional*string #
The object key prefix to use in the redirect request.
notes

For example, to redirect requests for all pages with prefix docs/ (objects in the docs/ folder) to documents/ , you can set a condition block with KeyPrefixEquals set to docs/ and in the Redirect set ReplaceKeyPrefixWith to /documents . Not required if one of the siblings is present. Can be present only if ReplaceKeyWith is not provided.

Replacement must be made for object keys containing special characters (such as carriage returns) when using XML requests. For more information, see XML related object key constraints .

replaceKeyWithoptionalstringreplace_key_withoptionalstrreplaceKeyWithoptionalStringReplaceKeyWithoptionalstringReplaceKeyWithoptional*string #
The specific object key to use in the redirect request.
notes

For example, redirect request to error.html . Not required if one of the siblings is present. Can be present only if ReplaceKeyPrefixWith is not provided.

Replacement must be made for object keys containing special characters (such as carriage returns) when using XML requests. For more information, see XML related object key constraints .