ALIYUN::ESA::RedirectRule

ALIYUN::ESA::RedirectRule类型用于创建重定向配置。

语法

{
  "Type": "ALIYUN::ESA::RedirectRule",
  "Properties": {
    "ReserveQueryString": String,
    "SiteId": Integer,
    "StatusCode": Integer,
    "Type": String,
    "TargetUrl": String,
    "RuleEnable": String,
    "Rule": String,
    "RuleName": String,
    "SiteVersion": Integer
  }
}

属性

属性名称

类型

必须

允许更新

描述

约束

ReserveQueryString

String

保留查询字符串。

取值范围:

  • on:开启。

  • off:关闭。

SiteId

Integer

站点 ID。

StatusCode

Integer

节点给客户端响应重定向地址时候使用的响应状态码。

取值范围:

  • 301

  • 302

  • 303

  • 307

  • 308

Type

String

重定向类型。

取值范围:

  • static:静态模式。

  • dynamic:动态模式。

TargetUrl

String

重定向后的目标 URL。

RuleEnable

String

规则开关。

添加全局配置的时候不需要设置该参数。取值范围:

  • on:开启。

  • off:关闭。

Rule

String

规则内容。

使用条件表达式来匹配用户请求。添加全局配置的时候不需要设置该参数。存在两种使用场景:

  • 匹配所有传入请求:值设置为 true

  • 匹配指定请求:值设置为自定义表达式,例如:(http.host eq "video.example.com")

RuleName

String

规则名称。

SiteVersion

Integer

站点配置的版本号。

开启了配置版本管理的站点,可以通过该参数指定配置生效的站点版本,默认为版本 0。

返回值

Fn::GetAtt

  • Type:重定向类型。

  • RuleEnable:规则开关。

  • ReserveQueryString:保留查询字符串。

  • Sequence:规则执行顺序

  • Rule:规则内容

  • TargetUrl:重定向后的目标 URL。

  • ConfigId:配置 ID。

  • SiteVersion:站点配置的版本号。

  • ConfigType:配置类型

  • StatusCode:节点给客户端响应重定向地址时候使用的响应状态码。

  • RuleName:规则名称。

示例

ROSTemplateFormatVersion: '2015-09-01'
Parameters:
  SiteId:
    Type: Number
    Description:
      en: The website ID.
    Required: true
  Type:
    Type: String
    Description:
      en: |-
        The redirect type. Valid value:
        *   static.
    AllowedValues:
      - static
    Required: true
  RuleEnable:
    Type: String
    Description:
      en: |-
        Rule switch. When adding global configuration, this parameter does not need to be set. Value range:
        on
        off.
    AllowedValues:
      - 'on'
      - 'off'
    Required: false
  ReserveQueryString:
    Type: String
    Description:
      en: |-
        Indicates whether the feature of retaining the query string is enabled. Valid values:
        on
        off.
    AllowedValues:
      - 'on'
      - 'off'
    Required: true
  TargetUrl:
    Type: String
    Description:
      en: The destination URL to which requests are redirected.
    Required: true
  Rule:
    Type: String
    Description:
      en: |-
        Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:
         Match all incoming requests: value set to true
         Match specified request: Set the value to a custom expression, for example: (http.host eq \"video.example.com\").
    Required: false
  StatusCode:
    Type: Number
    Description:
      en: |-
        The response code that you want to use to indicate URL redirection. Valid values:
        *   301
        *   302
        *   303
        *   307
        *   308.
    AllowedValues:
      - 301
      - 302
      - 303
      - 307
      - 308
    Required: true
  RuleName:
    Type: String
    Description:
      en: Rule name. When adding global configuration, this parameter does not need to be set.
    Required: false
Resources:
  ExtensionResource:
    Type: ALIYUN::ESA::RedirectRule
    Properties:
      SiteId:
        Ref: SiteId
      Type:
        Ref: Type
      RuleEnable:
        Ref: RuleEnable
      ReserveQueryString:
        Ref: ReserveQueryString
      TargetUrl:
        Ref: TargetUrl
      Rule:
        Ref: Rule
      StatusCode:
        Ref: StatusCode
      RuleName:
        Ref: RuleName
Outputs:
  Type:
    Description: The redirect type.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Type
  RuleEnable:
    Description: Rule switch. When adding global configuration, this parameter does not need to be set.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - RuleEnable
  ReserveQueryString:
    Description: Indicates whether the feature of retaining the query string is enabled.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - ReserveQueryString
  Sequence:
    Description: Order of rule execution. The smaller the value, the higher the priority for execution.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Sequence
  Rule:
    Description: Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - Rule
  TargetUrl:
    Description: The destination URL to which requests are redirected.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - TargetUrl
  ConfigId:
    Description: Config Id.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - ConfigId
  SiteVersion:
    Description: The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - SiteVersion
  ConfigType:
    Description: The type of the configuration.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - ConfigType
  StatusCode:
    Description: The response code that you want to use to indicate URL redirection.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - StatusCode
  RuleName:
    Description: Rule name. When adding global configuration, this parameter does not need to be set.
    Value:
      Fn::GetAtt:
        - ExtensionResource
        - RuleName
{
  "ROSTemplateFormatVersion": "2015-09-01",
  "Parameters": {
    "SiteId": {
      "Type": "Number",
      "Description": {
        "en": "The website ID."
      },
      "Required": true
    },
    "Type": {
      "Type": "String",
      "Description": {
        "en": "The redirect type. Valid value:\n*   static."
      },
      "AllowedValues": [
        "static"
      ],
      "Required": true
    },
    "RuleEnable": {
      "Type": "String",
      "Description": {
        "en": "Rule switch. When adding global configuration, this parameter does not need to be set. Value range:\non\noff."
      },
      "AllowedValues": [
        "on",
        "off"
      ],
      "Required": false
    },
    "ReserveQueryString": {
      "Type": "String",
      "Description": {
        "en": "Indicates whether the feature of retaining the query string is enabled. Valid values:\non\noff."
      },
      "AllowedValues": [
        "on",
        "off"
      ],
      "Required": true
    },
    "TargetUrl": {
      "Type": "String",
      "Description": {
        "en": "The destination URL to which requests are redirected."
      },
      "Required": true
    },
    "Rule": {
      "Type": "String",
      "Description": {
        "en": "Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set. There are two usage scenarios:\n Match all incoming requests: value set to true\n Match specified request: Set the value to a custom expression, for example: (http.host eq \\\"video.example.com\\\")."
      },
      "Required": false
    },
    "StatusCode": {
      "Type": "Number",
      "Description": {
        "en": "The response code that you want to use to indicate URL redirection. Valid values:\n*   301\n*   302\n*   303\n*   307\n*   308."
      },
      "AllowedValues": [
        301,
        302,
        303,
        307,
        308
      ],
      "Required": true
    },
    "RuleName": {
      "Type": "String",
      "Description": {
        "en": "Rule name. When adding global configuration, this parameter does not need to be set."
      },
      "Required": false
    }
  },
  "Resources": {
    "ExtensionResource": {
      "Type": "ALIYUN::ESA::RedirectRule",
      "Properties": {
        "SiteId": {
          "Ref": "SiteId"
        },
        "Type": {
          "Ref": "Type"
        },
        "RuleEnable": {
          "Ref": "RuleEnable"
        },
        "ReserveQueryString": {
          "Ref": "ReserveQueryString"
        },
        "TargetUrl": {
          "Ref": "TargetUrl"
        },
        "Rule": {
          "Ref": "Rule"
        },
        "StatusCode": {
          "Ref": "StatusCode"
        },
        "RuleName": {
          "Ref": "RuleName"
        }
      }
    }
  },
  "Outputs": {
    "Type": {
      "Description": "The redirect type.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Type"
        ]
      }
    },
    "RuleEnable": {
      "Description": "Rule switch. When adding global configuration, this parameter does not need to be set.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "RuleEnable"
        ]
      }
    },
    "ReserveQueryString": {
      "Description": "Indicates whether the feature of retaining the query string is enabled.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "ReserveQueryString"
        ]
      }
    },
    "Sequence": {
      "Description": "Order of rule execution. The smaller the value, the higher the priority for execution.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Sequence"
        ]
      }
    },
    "Rule": {
      "Description": "Rule content, using conditional expressions to match user requests. When adding global configuration, this parameter does not need to be set.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "Rule"
        ]
      }
    },
    "TargetUrl": {
      "Description": "The destination URL to which requests are redirected.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "TargetUrl"
        ]
      }
    },
    "ConfigId": {
      "Description": "Config Id.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "ConfigId"
        ]
      }
    },
    "SiteVersion": {
      "Description": "The version number of the site configuration. For sites that have enabled configuration version management, this parameter can be used to specify the effective version of the configuration site, which defaults to version 0.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "SiteVersion"
        ]
      }
    },
    "ConfigType": {
      "Description": "The type of the configuration.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "ConfigType"
        ]
      }
    },
    "StatusCode": {
      "Description": "The response code that you want to use to indicate URL redirection.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "StatusCode"
        ]
      }
    },
    "RuleName": {
      "Description": "Rule name. When adding global configuration, this parameter does not need to be set.",
      "Value": {
        "Fn::GetAtt": [
          "ExtensionResource",
          "RuleName"
        ]
      }
    }
  }
}