title: One Apigee Api Proxy with a different target endpoint for each environment
body: <p>I am an Apigee newbie.</p>
  
  <p>We have our environments in our host names, for example:</p>
  
  <pre><code>something.int.other.thing.co.uk
  something.test.other.thing.co.uk
  something.stage.other.thing.co.uk
  something.prod.other.thing.co.uk
  </code></pre>
  
  <p>I would like to be able to map them to the 4 environments of the apigee api proxy itself, respectively <strong>int, test, stage, prod</strong>.</p>
  
  <p>I currently have one Rest resource for them, for example: <code>/resource</code></p>
  
  <p>Basically I would like the apigee api proxy with one rest resource, to map to 4 different target endpoints, depending on the environment.</p>
  
  <p>So far I have tried to do it from the UI and have not been able to do so.</p>
  
  <p>I have been going through the documentation and I have found these so far:</p>
  
  <ul>
  <li>According to this it should be possible:
  "An API proxy can contain zero or more TargetEndpoints." (TargetEndpoint section)</li>
  </ul>
  
  <p><a href="http://apigee.com/docs/api-services/content/api-proxy-configuration-reference" rel="nofollow noreferrer">http://apigee.com/docs/api-services/content/api-proxy-configuration-reference</a></p>
  
  <ul>
  <li>According to these, you can make routerules to the proxy endpoint, but I have not been able to implement it to the targetendpoint:</li>
  </ul>
  
  <p><a href="https://stackoverflow.com/questions/22569963/create-a-new-endpoint-on-an-existing-api-proxy-with-no-target-endpoint/22585111#22585111">Create a New Endpoint on an existing API Proxy with &quot;No Target Endpoint&quot;</a></p>
  
  <p><a href="https://stackoverflow.com/questions/22783986/one-api-proxy-calling-two-different-target-endpoints/22791169#22791169">One API proxy calling two different target endpoints</a></p>
  
  <p>I also tried doing something along the lines of this, for TargetEndpoint, where I tested for the environment name, but it didn't work:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;TargetEndpoint name="default"&gt;
      &lt;Description/&gt;
      &lt;Flows/&gt;
      &lt;PreFlow name="PreFlow"&gt;
          &lt;Request/&gt;
          &lt;Response/&gt;
      &lt;/PreFlow&gt;
      &lt;HTTPTargetConnection&gt;
          &lt;URL&gt;something.int.other.thing.co.uk&lt;/URL&gt;
      &lt;/HTTPTargetConnection&gt;
      &lt;RouteRule name="int"&gt;
          &lt;Condition&gt;environment.name == "int"&lt;/Condition&gt;
          &lt;TargetEndpoint&gt;something.int.other.thing.co.uk&lt;/TargetEndpoint&gt;
      &lt;/RouteRule&gt;
      &lt;RouteRule name="test"&gt;
          &lt;Condition&gt;environment.name == "test"&lt;/Condition&gt;
          &lt;TargetEndpoint&gt;something.test.other.thing.co.uk/&lt;/TargetEndpoint&gt;
      &lt;/RouteRule&gt;
      &lt;RouteRule name="stage"&gt;
          &lt;Condition&gt;environment.name == "stage"&lt;/Condition&gt;
          &lt;TargetEndpoint&gt;something.stage.other.thing.co.uk/&lt;/TargetEndpoint&gt;
      &lt;/RouteRule&gt;
      &lt;RouteRule name="prod"&gt;
          &lt;Condition&gt;environment.name == "prod"&lt;/Condition&gt;
          &lt;TargetEndpoint&gt;something.prod.other.thing.co.uk&lt;/TargetEndpoint&gt;
      &lt;/RouteRule&gt;
      &lt;PostFlow name="PostFlow"&gt;
          &lt;Request/&gt;
          &lt;Response/&gt;
      &lt;/PostFlow&gt;
  &lt;/TargetEndpoint&gt;
  </code></pre>
  
  <p>So is this possible?</p>
  
  <p>Can you please advise me on how to do that?</p>
  
  <p>We are doing a migration to Apigee and we have a hard deadline, so any help will be appreciated!</p>
  
  <p>Thanks!</p>