Terraformを使用してルールを作成する
以下の例は、Terraformを使用してゾーンのための単一のリダイレクトルールを定義します。このルールは、古いURLを使用して連絡先ページをリクエストする訪問者のために、静的なURLリダイレクトを作成します。
# 単一リダイレクトリソースresource "cloudflare_ruleset" "single_redirects_example" { zone_id = "<ZONE_ID>" name = "redirects" description = "リダイレクトルールセット" kind = "zone" phase = "http_request_dynamic_redirect"
rules { action = "redirect" action_parameters { from_value { status_code = 301 target_url { value = "/contacts/" } preserve_query_string = false } } expression = "(http.request.uri.path matches \"^/contact-us/\")" description = "古いURLを使用している訪問者をリダイレクト" enabled = true }}For additional guidance on using Terraform with Cloudflare, refer to the following resources:
- Terraform documentation
- Cloudflare Provider for Terraform ↗ (reference documentation)