title: Spring Cloud Gateway - Redirect Based on Header
body: <p>Just using Spring Cloud Gateway, I'm currently proxying a remote site with the following route (defined in Kotlin):</p>
  
  <pre><code>@GetMapping("/proxgoo/**")
  @Throws(Exception::class)
  fun proxyPath(proxy: ProxyExchange&lt;*&gt;): ResponseEntity&lt;*&gt; {
      val path = proxy.path("/proxgoo/")
      return proxy.uri(proxiedRemote.toString() + "/" + path).get()
  }
  </code></pre>
  
  <p>Which works nicely. If we set the <code>proxiedRemote</code> to <code>https://www.google.com</code>, this works great untill we try to load the external resources (like the images).</p>
  
  <p>The problem is that something like: </p>
  
  <p><code>http://localhost:8081/logos/doodles/2018/**</code></p>
  
  <p>Really should be going out to:</p>
  
  <p><code>http://localhost:8081/proxgoo/logos/doodles/2018/**</code></p>
  
  <p>I was thinking that if I could redirect everything, where the <strong>Referer</strong> header is <code>http://localhost:8081/proxgoo/</code> back onto the proxy route, then this would be all that I need:</p>
  
  <hr>
  
  <p>So, the actual question. I thought that the following config would redirect everything with the request header <strong>Referer</strong>=<code>http://localhost:8081/proxgoo/</code>, but it doesn't pick it up. Have I done something silly?</p>
  
  <pre><code>spring:
    cloud:
      gateway:
        routes:
        - id: redirect_on_referer
          predicates:
          - Header=Referer,http://localhost:8081/proxgoo/
          filters:
          - RedirectTo=302, http://localhost:8081/proxgoo/
  </code></pre>