After wasting time with react router, I finally switch to basic javascript.
-
Create a component for your redirect:
Route path=”*” component={NotFound}
-
In the component use window.location to redirect:
componentDidMount() { if (typeof window !== 'undefined') { window.location.href = "http://foo.com/error.php"; } }