[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["很难理解","hardToUnderstand","thumb-down"],["信息或示例代码不正确","incorrectInformationOrSampleCode","thumb-down"],["没有我需要的信息/示例","missingTheInformationSamplesINeed","thumb-down"],["翻译问题","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-08-07。"],[[["\u003cp\u003eThis documentation covers routing in Apigee and Apigee hybrid, detailing how requests are directed from the \u003ccode\u003eProxyEndpoint\u003c/code\u003e to the \u003ccode\u003eTargetEndpoint\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe URL used to access an API \u003ccode\u003eProxyEndpoint\u003c/code\u003e includes a hostname, base path, and resource, all of which are parsed by Apigee to route incoming requests correctly.\u003c/p\u003e\n"],["\u003cp\u003eA \u003ccode\u003eProxyEndpoint\u003c/code\u003e can be configured to direct requests to a backend service via a direct URL, a single named \u003ccode\u003eTargetEndpoint\u003c/code\u003e, multiple conditional \u003ccode\u003eTargetEndpoint\u003c/code\u003es, or a null route.\u003c/p\u003e\n"],["\u003cp\u003eConditional routing, determined by the \u003ccode\u003e<RouteRule>\u003c/code\u003e tag, enables requests to be directed to different \u003ccode\u003eTargetEndpoint\u003c/code\u003es based on various conditions such as HTTP headers, query parameters, or message content.\u003c/p\u003e\n"],["\u003cp\u003eThe order of \u003ccode\u003e<RouteRule>\u003c/code\u003e definitions within a \u003ccode\u003eProxyEndpoint\u003c/code\u003e is crucial, with conditional rules preceding the default, unconditional rule to ensure correct evaluation and execution.\u003c/p\u003e\n"]]],[],null,["*This page\napplies to **Apigee** and **Apigee hybrid**.*\n\n\n*View [Apigee Edge](https://docs.apigee.com/api-platform/get-started/what-apigee-edge) documentation.*\n\nA route determines the path of a request from the `ProxyEndpoint` to the\n`TargetEndpoint`. Included in the route is the URL used to access the API\n`ProxyEndpoint` and the URL of the backend service defined by the\n`TargetEndpoint`.\n**Note:** This video was recorded with a previous version of the Apigee UI; however, the concepts are still valid. \nWatch this video for an introduction to routes, describing the relationship between the\n`ProxyEndpoint` and the `TargetEndpoint`. \n\nDetermining the URL of the API proxy\nendpoint\n\nThe following image shows a request coming in to the `ProxyEndpoint` from an app, and that\nrequest being directed to the backend service:\n\nAfter you create an API proxy on Apigee, the default URL that an app uses to access the proxy\nhas the following form: \n\n```\nhttps://www.example.com/shopping/cart/addItem\n |_____________| |___________| |_____|\n | | |\n hostname basepath resource\n```\n\nWhere:\n\n- The hostname is either a domain that you have added to DNS or an IP address.\n- The base path and resource-path are defined when you create the API proxy.\n\nWhen a request comes in to Apigee, Apigee parses the URL to direct the request to the correct\n`ProxyEndpoint`. For example, the following URL is used to access an API proxy: \n\n```text\nhttp://example.com/v1/weather/forecastrss\n```\n\nIf you examine the `ProxyEndpoint` definition for the API proxy in the figure above,\nyou can see how this URL is parsed:\n\n1. The domain portion of the URL, `http://example.com`, corresponds to a host name defined on an environment group. The proxy was deployed to one or more environments within that environment group. For more information, see [About environments and\n environment groups](/apigee/docs/api-platform/fundamentals/environments-overview).\n2. The second part of the URL, `/v1/weather`, is determined by the `\u003cBasePath\u003e` element in the `ProxyEndpoint`. You defined the base path when you created the proxy. The base path must be unique to the API proxy for the environment so that two API proxies in the same environment do not have the same base path.\n3. The third part of the URL, `/forecastrss`, is a resource defined by the API proxy with the corresponding conditional flow defined by the `\u003cFlows\u003e` element.\n\n**Note:** This video was recorded with a previous version of the Apigee UI; however, the concepts are still valid. \n**Video:** Watch a short video to learn more about API proxy endpoints. \n\nDetermining the URL of the target endpoint\n\nThe `\u003cRouteRule\u003e` element in a\n`ProxyEndpoint` definition determines the target of the API proxy, and is evaluated after all\npolicies in the PreFlow, Conditional Flows, and PostFlow of the `ProxyEndpoint` request are\nprocessed.\n\nA `ProxyEndpoint` can define the target as:\n\n- A direct URL to a backend service.\n- A single `TargetEndpoint` definition.\n- Multiple `TargetEndpoint`s where the API proxy delegates the request to a target endpoint based on a condition.\n- Null route or target, meaning the request is not forwarded to a target. Instead, all of the processing of the request, and the generation of the response, occurs on Apigee.\n\n**Note:** This video was recorded with a previous version of the Apigee UI; however, the concepts are still valid. \n**Video:** Watch a short video to learn more about target endpoints. \n\nDirect URL\n\nA `ProxyEndpoint` can directly invoke a backend service, bypassing any named\n`TargetEndpoint`\nconfiguration. For example, the following `\u003cRouteRule\u003e` always makes an HTTP\ncall to `http://example.com/myAPI:` \n\n```text\n\u003cRouteRule name=\"default\"\u003e\n \u003cURL\u003ehttp://example.com/myAPI\u003c/URL\u003e\n\u003c/RouteRule\u003e\n```\n\nHowever, because there is no `TargetEndpoint`, you can only add policies to the\nflows defined by the `ProxyEndpoint`.\n\nSingle target\n\nIn a single target definition, the `ProxyEndpoint` references a single\n`TargetEndpoint` definition by name, as shown in the figure above: \n\n```text\n\u003cRouteRule name=\"default\"\u003e\n \u003cTargetEndpoint\u003edefault\u003c/TargetEndpoint\u003e\n\u003c/RouteRule\u003e\n```\n\nAll requests to this API proxy are directed to the same `TargetEndpoint` definition. The\n`\u003cURL\u003e` tag in the\n`TargetEndpoint` determines the location of the backend service. in the figure above,\nthe target URL is `http://weather.yahooapis.com`.\n\nConditional targets\n\nThe `\u003cRouteRule\u003e` tag lets\nyou direct a request to a target based on a condition. You can use flow variables, query\nparameters, HTTP headers, message content, or contextual information such time of day and locale\nto determine the target endpoint. For example, you might include a geographical area, such as US\nand UK, in a request URL. You can then route a request to a target endpoint based on the\nregion.\n\nThe following route rule evaluates an HTTP header in a request. If the HTTP header\n`routeTo` has the value\n`TargetEndpoint1`, then the request\nis forwarded to the `TargetEndpoint` named `TargetEndpoint1`. If not, then\nthe request is forwarded to `TargetEndpoint2`. \n\n```text\n\u003cRouteRule name=\"MyRoute\"\u003e\n \u003cCondition\u003erequest.header.routeTo = \"TargetEndpoint1\"\u003c/Condition\u003e\n \u003cTargetEndpoint\u003eTargetEndpoint1\u003c/TargetEndpoint\u003e\n\u003c/RouteRule\u003e\n\u003cRouteRule name=\"default\"\u003e\n \u003cTargetEndpoint\u003eTargetEndpoint2\u003c/TargetEndpoint\u003e\n\u003c/RouteRule\u003e\n```\n\nIf you have multiple route rules, create one as the *default* , that is, as a route\nrule with no condition. Ensure that the default route rule is defined last in the list\nof conditional routes because rules are evaluated top-down in the `ProxyEndpoint`.\n\nSee also [Conditional routes](/apigee/docs/api-platform/reference/api-proxy-configuration-reference#proxyendpoint-conditionalroutes)\nand [Conditions reference](/apigee/docs/api-platform/reference/conditions-reference).\n\n| **Note:** **Order is important** :\n|\n| If you have more than one\n| `RouteRule` in a `ProxyEndpoint`, their order in the XML configuration is\n| important. The first\n| `RouteRule` to *match* gets executed. (`RouteRule` with no condition\n| always match.)\n|\n| In the previous example, if the unconditional *default* `RouteRule` came\n| first, it would be executed even if the condition of the `MyRoute` rule would have\n| matched. So list your conditional `RouteRule` before an unconditional\n| `RouteRule`.\n**Note:** This video was recorded with a previous version of the Apigee UI; however, the concepts are still valid. \n**Video:** Watch a short video to learn how to route to a target endpoint using\nconditional targets. \n\nNull route\n\nA null route supports scenarios in which the request message does not need to be forwarded to\na `TargetEndpoint`. This is useful when the `ProxyEndpoint` performs all\nof the necessary processing,\nfor example by using JavaScript to call an external service.\n\nThe following example defines a null route: \n\n```text\n\u003cRouteRule name=\"GoNowhere\"/\u003e\n```\n\nLearn more\n\n- [API proxy configuration reference](/apigee/docs/api-platform/reference/api-proxy-configuration-reference)\n- [Endpoint properties reference](/apigee/docs/api-platform/reference/endpoint-properties-reference)\n- [Load balancing\n across backend servers](/apigee/docs/api-platform/deploy/load-balancing-across-backend-servers)"]]