Class RelativeRedirectFilter

All Implemented Interfaces:
Filter, Aware, BeanNameAware, DisposableBean, InitializingBean, EnvironmentAware, EnvironmentCapable, ServletContextAware

public class RelativeRedirectFilter extends OncePerRequestFilter
Overrides HttpServletResponse.sendRedirect(String) and handles it by setting the HTTP status and "Location" headers, which keeps the Servlet container from re-writing relative redirect URLs into absolute ones. Servlet containers are required to do that but against the recommendation of RFC 7231 Section 7.1.2, and furthermore not necessarily taking into account "X-Forwarded" headers.

Note: While relative redirects are recommended in the RFC, under some configurations with reverse proxies they may not work.

Rob Winch, Rossen Stoyanchev