【发布时间】:2020-12-05 20:07:51
【问题描述】:
我在根域假设 domain.com 安装了一个 react 应用程序,并且我已经在名为 domain.com/blog 的子目录中安装了 Wordpress。如果我添加像 <Route exact path="/blog" /> 这样的空路线,我会得到一个空白页。
有没有办法访问 react 组件之外的子目录中的 .php 或 .html 文件?
请参考下面的路由代码
<BrowserRouter>
<Switch>
<Switch>
<Route exact path="/" render={(props) => <Index {...props} />} />
{/*route added since /blog redirects to / because of 404 condition at the bottom */}
{/* <Route exact path="/blog" /> */}
{/*404 redirection for other URLs */}
<Redirect to="/" />
<Redirect from="/" to="/" />
</Switch>
</Switch>
</BrowserRouter>
由于下面添加的重定向,如果我不为 /blog 提供路由,它会重定向到根 '/' URL(这是 404 页面未找到条件)。
【问题讨论】:
标签: php html reactjs wordpress react-router