title: Spring Security - Change all instances of RedirectStrategy
body: <p>I have a tomcat instance that is running multiple WAR files. The tomcat instance is proxied behind an Apache server so that the context paths are stripped out. Instead, I am using subdomains:</p>
  
  <p>Basically, my setup looks like this:</p>
  
  <pre><code>http://localhost:8080/app1 -&gt; http://app1.example.com/
  http://localhost:8080/app2 -&gt; http://app2.example.com/
  </code></pre>
  
  <p>What I need to happen is to make all redirects context relative since I no longer include the context path in the URL. I've noticed that Spring Security allows for setting redirects to be "context relative" with the default class DefaultRedirectStrategy. In order to get the redirects working properly, I have to override multiple objects just so that I can simply swap out the default instance of DefaultRedirectStrategy with contextRelative=false to my own created instance of DefaultRedirectStrategy with contextRelative=true. </p>
  
  <p>Is there an easier way where I can just tell spring that I want to globally redirect all URLs without the context path? I have already tried registering DefaultRedirectStrategy in my configuration but that did not work.</p>
  
  <pre><code>@Bean
  public RedirectStrategy createRedirectStrategy()
  {
      // create the redirect strategy to set the urls to context relative
      DefaultRedirectStrategy redirectStrategy = new DefaultRedirectStrategy();
      redirectStrategy.setContextRelative(true);
  
      return redirectStrategy;
  }
  </code></pre>
  
  <p>^ This would have been too easy. Not sure why spring doesn't allow this to work.</p>
  
  <p>Am I looking in the wrong place?</p>