在子目录上部署Reactjs后路由不起作用

时间:2020-10-21 11:17:13

标签: reactjs react-router

我在本地主机上使用ReactJS创建了一个简单的登录页面,它在http:// localhost:3000上运行良好。然后我想捕获一些营销参数,我这样做是用的,它也可以正常工作,但是在部署它时,使用这些参数时会出现空白页面。

App.js

     <Switch>
          <Route path="/" children={<Normal />} />
      </Switch>
      <Switch>
          <Route path="/:cn/:cid" children={<Markdata />} />
      </Switch>

.htaccess

RewriteEngine On
RewriteBase /
RewriteRule ^index.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]

package.json

....
"name": "muslimsgate",
  "homepage": ".",
  "version": "0.1.0",
  "private": true,
....

.env文件

/* /index.html 200

0 个答案:

没有答案