[英]404 Not Found page - reactjs
I uploaded my site on server and my site works fine. 我将网站上传到服务器上,并且网站运行正常。 but I have a problem.
但是我有问题
when I go to route A
from route B
, B
component loaded as well. 当我从路线
B
转到路线A
,也会加载B
组件。 but when I copy my B
component url I got 404 Not Found page
. 但是,当我复制
B
组件的url时,出现404 Not Found page
。
for example when I copy/paste this url: 例如,当我复制/粘贴此网址时:
http://test.shadyab.com/offers/Arya-Ceremonial-Pool-VIP-off http://test.shadyab.com/offers/Arya-Ceremonial-Pool-VIP-off
I got a 404 Not Found page
. 我有一个
404 Not Found page
。
my route: 我的路线:
import React from 'react'
import { Provider } from 'react-redux'
import { Router, Route, IndexRoute } from 'react-router'
import configureStore from 'store/configureStore'
import App from 'containers/App'
import Home from 'containers/Home'
import Detail from 'containers/Detail'
import Cart from 'containers/Cart'
import Login from 'containers/Login'
import Profile from 'containers/Profile'
import Category from 'containers/Category'
export default function(history) {
return (
<Router history={history}>
<Route path="/" component={App}>
<Route exact path="/offers/:id" component={Detail} />
<Route path="/cart/cart" component={Cart} />
<Route path="/login" component={Login} />
<Route path="/profile/:section" component={Profile} />
<Route path="/category/:city/:category" component={Category} />
<IndexRoute component={Home} />
</Route>
</Router>
)
}
my app.js
: 我的
app.js
:
import 'babel-polyfill'
import React from 'react'
import ReactDOM from 'react-dom'
import { browserHistory } from 'react-router'
import configureStore from 'store/configureStore'
import createRoutes from 'routes/index'
import { Provider } from 'react-redux'
import Immutable from 'immutable'
import _ from 'lodash'
let reduxState = {}
if (window.__REDUX_STATE__) {
try {
let plain = JSON.parse(unescape(__REDUX_STATE__))
_.each(plain, (val, key)=> {
reduxState[key] = Immutable.fromJS(val)
})
} catch (e) {
}
}
const store = configureStore(reduxState)
ReactDOM.render((
<Provider store={store}>
{ createRoutes(browserHistory) }
</Provider>
), document.getElementById('root'))
Even if the user wants to refresh the current webpage, he will receive a 404 error. 即使用户想要刷新当前网页,他也会收到404错误。
my server language is php. 我的服务器语言是php。
You need to configure your server to always serve your index.html
file for all urls. 您需要将服务器配置为始终为所有URL提供
index.html
文件。
Here is one of the example how to do it in NodeJS. 这是如何在NodeJS中执行此操作的示例之一。
https://stackoverflow.com/a/25374786/3187014 https://stackoverflow.com/a/25374786/3187014
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.