Skip to content

Instantly share code, notes, and snippets.

@topera
Created July 8, 2018 13:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save topera/910005f64dfd9abe1ccee726c6ef2d12 to your computer and use it in GitHub Desktop.
Save topera/910005f64dfd9abe1ccee726c6ef2d12 to your computer and use it in GitHub Desktop.
Controller for springboot that redirects any url to /
@Controller
public class ForwardingController {
@RequestMapping("/**/{path:[^\\.]+}")
public String forward() {
// path: checks only the path of url
// [^\.]: any char, except literal dot (because if the url is foo.css (for example) we don't want to redirect)
return "forward:/";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment