# RoutingRule

Rule that define when a redirect is applied and the redirect behavior.

- Source: [`aws-s3/lib/bucket.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L3884)

## Example

TypeScript:

```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';

declare const replaceKey: s3.ReplaceKey;
const routingRule: s3.RoutingRule = {
  condition: {
    httpErrorCodeReturnedEquals: 'httpErrorCodeReturnedEquals',
    keyPrefixEquals: 'keyPrefixEquals',
  },
  hostName: 'hostName',
  httpRedirectCode: 'httpRedirectCode',
  protocol: s3.RedirectProtocol.HTTP,
  replaceKey: replaceKey,
};
```

Python:

```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

# replace_key: s3.ReplaceKey

routing_rule = s3.RoutingRule(
    condition=s3.RoutingRuleCondition(
        http_error_code_returned_equals="httpErrorCodeReturnedEquals",
        key_prefix_equals="keyPrefixEquals"
    ),
    host_name="hostName",
    http_redirect_code="httpRedirectCode",
    protocol=s3.RedirectProtocol.HTTP,
    replace_key=replace_key
)
```

Java:

```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.*;

ReplaceKey replaceKey;

RoutingRule routingRule = RoutingRule.builder()
        .condition(RoutingRuleCondition.builder()
                .httpErrorCodeReturnedEquals("httpErrorCodeReturnedEquals")
                .keyPrefixEquals("keyPrefixEquals")
                .build())
        .hostName("hostName")
        .httpRedirectCode("httpRedirectCode")
        .protocol(RedirectProtocol.HTTP)
        .replaceKey(replaceKey)
        .build();
```

C# / .NET:

```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;

ReplaceKey replaceKey;

var routingRule = new RoutingRule {
    Condition = new RoutingRuleCondition {
        HttpErrorCodeReturnedEquals = "httpErrorCodeReturnedEquals",
        KeyPrefixEquals = "keyPrefixEquals"
    },
    HostName = "hostName",
    HttpRedirectCode = "httpRedirectCode",
    Protocol = RedirectProtocol.HTTP,
    ReplaceKey = replaceKey
};
```

Golang:

```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"

var replaceKey ReplaceKey

routingRule := &RoutingRule{
	Condition: &RoutingRuleCondition{
		HttpErrorCodeReturnedEquals: jsii.String("httpErrorCodeReturnedEquals"),
		KeyPrefixEquals: jsii.String("keyPrefixEquals"),
	},
	HostName: jsii.String("hostName"),
	HttpRedirectCode: jsii.String("httpRedirectCode"),
	Protocol: awscdk.Aws_s3.RedirectProtocol_HTTP,
	ReplaceKey: replaceKey,
}
```

## Properties

- `condition`: [RoutingRuleCondition](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.RoutingRuleCondition.html) — Specifies a condition that must be met for the specified redirect to apply.

  **Default:** No condition

- `hostName`: string — The host name to use in the redirect request.

  **Default:** The host name used in the original request.

- `httpRedirectCode`: string — The HTTP redirect code to use on the response.

  **Default:** "301" - Moved Permanently

- `protocol`: [RedirectProtocol](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.RedirectProtocol.html) — Protocol to use when redirecting requests.

  **Default:** The protocol used in the original request.

- `replaceKey`: [ReplaceKey](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_s3.ReplaceKey.html) — Specifies the object key prefix to use in the redirect request.

  **Default:** The key will not be replaced
