我的routes.js为
import {
BrowserRouter as Router,
Route
} from 'react-router-dom';
<Router>
<div>
<Route exact path="/" component={login}/>
<Route path="/calculator" component={calculatorPage}/>
<Route path="/result" component={resultPage}/>
</div>
</Router>
我已经在服务器上提升了应用程序,当我尝试使用/ calculator输入URL时,我收到404错误。如果我使用主页URL,到计算器页面,它工作正常。如果我直接进入,那么我得到404错误。
在我当地一切正常。即使我直接输入/计算器,我也会得到页面。
答案 0 :(得分:0)
<强>的.htaccess 强>
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} -s [OR]
RewriteCond %{REQUEST_FILENAME} -l [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^.*$ - [NC,L]
RewriteBase /<YOUR_BASE_URL_HERE>/
RewriteRule ^(.*) index.html [NC,L]