我有以下Router.jsx,我想要完成的是将任何通配符重定向回根级别(主目录)。
即http://xxxxxxx.com/randomPath应重定向到-> http://xxxxxxx.com/
<Switch>
<Route exact path="/" component={Home} />
<Route path="/home" component={Home} />
<Route path="/faq" component={Faq} />
<Route path="/more" component={Faq} />
<Route path="/signup" component={SignUp} />
<Route path="/legal" component={Legal} />
<Route path="/ugc" component={Ugc} />
<Route path="/pricing" component={Pricing} />
<Redirect from="*" to='/' />
</Switch>
但是,在测试时,我得到的是:ERR_TOO_MANY_REDIRECTS
非常感谢您的帮助,提前谢谢!
发布于 2019-04-03 07:36:00
通常我只需要设置<Redirect to="/" />
(不需要额外的参数),它工作得很好。
https://stackoverflow.com/questions/55484742
复制相似问题