# 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.274.0/packages/aws-cdk-lib/aws-s3/lib/bucket.ts#L3840)

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

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

## Properties

- `condition`: [RoutingRuleCondition](/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](/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](/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
