[英]404 Not Found page - reactjs
我將網站上傳到服務器上,並且網站運行正常。 但是我有問題
當我從路線B
轉到路線A
,也會加載B
組件。 但是,當我復制B
組件的url時,出現404 Not Found page
。
例如,當我復制/粘貼此網址時:
http://test.shadyab.com/offers/Arya-Ceremonial-Pool-VIP-off
我有一個404 Not Found page
。
我的路線:
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>
)
}
我的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'))
即使用戶想要刷新當前網頁,他也會收到404錯誤。
我的服務器語言是php。
您需要將服務器配置為始終為所有URL提供index.html
文件。
這是如何在NodeJS中執行此操作的示例之一。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.