Version: v2025-01-13Includes use: Yes

Behavior name: Redirect

Respond to the client request with a redirect without contacting the origin. Specify the redirect as a path expression starting with a / character relative to the current root, or as a fully qualified URL. This behavior relies primarily on destination_hostname and destination_path to manipulate the hostname and path independently.

See also the redirectplus behavior, which allows you to use variables more flexibly to express the redirect's destination.

Default behavior

These samples reflect the behavior's default settings. You can use these as is in your configurations or make adjustments based on the behavior's available options.

data "akamai_property_rules_builder" "redirect" {
  rules_v2025_02_18 {
    name     = "Redirect"
    comments = "Responds to the client request with a redirect without contacting the origin."
    behavior {
      redirect {
        mobile_default_choice = "DEFAULT"
        destination_protocol = "SAME_AS_REQUEST"
        destination_hostname = "SAME_AS_REQUEST"
        destination_path = "OTHER"
        destination_path_other = ""
        query_string = "APPEND"
        response_code = 302
      }
    }
  }
}
"behaviors": [
  {
    "name": "redirect",
    "options": {
      "mobileDefaultChoice": "DEFAULT",
      "destinationProtocol": "SAME_AS_REQUEST",
      "destinationHostname": "SAME_AS_REQUEST",
      "destinationPath": "OTHER",
      "destinationPathOther": "",
      "queryString": "APPEND",
      "responseCode": 302
    }
  }
]

Options

Option Description
mobile_default_choice
The mobile browser response. Value is one of:
  • DEFAULT. Allows all other response_code values.
  • MOBILE. Allows only a 302 response code.
destination_protocol
Choose the protocol for the redirect URL. Value is one of:
  • SAME_AS_REQUEST. Pass through the original protocol.
  • HTTP. Use http.
  • HTTPS. Use https.
destination_hostname
Specify how to change the requested hostname, independently from the pathname. Value is one of:
  • SAME_AS_REQUEST. Preserves the hostname unchanged.
  • SUBDOMAIN. Prepends a subdomain from the destination_hostname_subdomain field.
  • SIBLING. Replaces the leftmost subdomain with the destination_hostname_sibling field.
  • OTHER. Specifies a static domain in the destination_hostname_other field.
destination_hostname_subdomain
Specifies a subdomain to prepend to the current hostname. For example, a value of m changes www.example.com to m.www.example.com.
destination_hostname_sibling
Specifies the subdomain with which to replace to the current hostname's leftmost subdomain. For example, a value of m changes www.example.com to m.example.com.
destination_hostname_other
Specifies the full hostname with which to replace the current hostname.
destination_path
Specify how to change the requested pathname, independently from the hostname. Value is one of:
  • SAME_AS_REQUEST. Preserves the current path unchanged.
  • PREFIX_REQUEST. Prepends a path with the destination_path_prefix field. You also have the option to specify a suffix using destination_path_suffix and destination_path_suffix_status.
  • OTHER. Replaces the current path with the destination_path_other field.
destination_path_prefix
When destination_path is set to PREFIX_REQUEST this prepends the current path. For example, a value of /prefix/path changes /example/index.html to /prefix/path/example/index.html.
destination_path_suffix_status
When destination_path is set to PREFIX_REQUEST this gives you the option of adding a suffix. Value is one of:
  • NO_SUFFIX. Specify if you want to preserve the end of the path unchanged.
  • SUFFIX. The destination_path_suffix provides the value.
destination_path_suffix
When destination_path is set to PREFIX_REQUEST this replaces the current path.
destination_path_other
When destination_path is set to PREFIX_REQUESTthis replaces the current path.
query_string
When set to APPEND passes incoming query string parameters as part of the redirect URL. Otherwise set this to IGNORE.
response_code
Specify the redirect's response code. Value is one of:
  • 301
  • 302
  • 303
  • 307