> **Experimental**
>
> `@aws-cdk/aws-amplify-alpha` is an [**experimental**](/stability) (alpha) package: its API may change in any release, without a major version bump.
# CustomRule

Custom rewrite/redirect rule for an Amplify App.

Obtainable from: CustomRule.SINGLE_PAGE_APPLICATION_REDIRECT

- Stability: [Experimental](/cdk/api/stability.html)
- Source: [`lib/app.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/@aws-cdk/aws-amplify-alpha/lib/app.ts#L533)

## Example

TypeScript:

```ts
import { CustomRule } from '@aws-cdk/aws-amplify-alpha';

declare const amplifyApp: amplify.App;
amplifyApp.addCustomRule(new CustomRule({
  source: '/docs/specific-filename.html',
  target: '/documents/different-filename.html',
  status: amplify.RedirectStatus.TEMPORARY_REDIRECT,
}));
```

Python:

```python
from aws_cdk.aws_amplify_alpha import CustomRule

# amplify_app: amplify.App

amplify_app.add_custom_rule(CustomRule(
    source="/docs/specific-filename.html",
    target="/documents/different-filename.html",
    status=amplify.RedirectStatus.TEMPORARY_REDIRECT
))
```

Java:

```java
import software.amazon.awscdk.services.amplify.alpha.CustomRule;

App amplifyApp;

amplifyApp.addCustomRule(CustomRule.Builder.create()
        .source("/docs/specific-filename.html")
        .target("/documents/different-filename.html")
        .status(RedirectStatus.TEMPORARY_REDIRECT)
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Amplify.Alpha
using Amazon.CDK.AWS.Amplify.Alpha;

App amplifyApp;

amplifyApp.AddCustomRule(new CustomRule(new CustomRuleOptions {
    Source = "/docs/specific-filename.html",
    Target = "/documents/different-filename.html",
    Status = RedirectStatus.TEMPORARY_REDIRECT
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdkamplifyalpha/v2
import "github.com/aws/aws-cdk-go/awscdkamplifyalpha"

var amplifyApp App

amplifyApp.AddCustomRule(awscdkamplifyalpha.NewCustomRule(&CustomRuleOptions{
	Source: jsii.String("/docs/specific-filename.html"),
	Target: jsii.String("/documents/different-filename.html"),
	Status: amplify.RedirectStatus_TEMPORARY_REDIRECT,
}))
```

## Initializer

TypeScript:

```ts
new CustomRule(options: CustomRuleOptions)
```

Python:

```python
CustomRule(options: CustomRuleOptions)
```

Java:

```java
new CustomRule(CustomRuleOptions options)
```

C# / .NET:

```csharp
new CustomRule(CustomRuleOptions options)
```

Golang:

```go
NewCustomRule(Options CustomRuleOptions)
```

## Properties

- `condition`: string — The condition for a URL rewrite or redirect rule, e.g. country code.

  **Default:** no condition

- `SINGLE_PAGE_APPLICATION_REDIRECT`: [CustomRule](/cdk/api/v2/docs/@aws-cdk_aws-amplify-alpha.CustomRule.html) (static) — Sets up a 200 rewrite for all paths to `index.html` except for path containing a file extension.

- `source`: string — The source pattern for a URL rewrite or redirect rule.

- `status`: [RedirectStatus](/cdk/api/v2/docs/@aws-cdk_aws-amplify-alpha.RedirectStatus.html) = PERMANENT_REDIRECT — The status code for a URL rewrite or redirect rule.

- `target`: string — The target pattern for a URL rewrite or redirect rule.
