我想设置AllowOverride all
但我不知道该怎么做.我通过搜索谷歌找到了以下代码并将其粘贴在.htaccess中
<Directory>
AllowOverride All
</Directory>
Run Code Online (Sandbox Code Playgroud)
但在粘贴之后我开始收到了 .htaccess
可以任何人指导我在哪里放置此代码或如何做到这一点?
/#/
使用react-router时,有什么方法可以阻止在浏览器的地址栏中显示?这与ReactJS有关.即点击链接转到新路线显示localhost:3000/#/
或
localhost:3000/#/about
.视路线而定.
我开始使用react-router v4.<Router>
我的app.js中有一个简单的导航链接(参见下面的代码).如果我导航到localhost/vocabulary
,路由器会将我重定向到正确的页面.但是,当我按下重新加载(F5)之后(localhost/vocabulary
)时,所有内容都会消失并且浏览器报告Cannot GET /vocabulary
.怎么可能?有人能给我任何线索如何解决(正确重新加载页面)?
App.js:
import React from 'react'
import ReactDOM from 'react-dom'
import { BrowserRouter as Router, Route, Link } from 'react-router-dom'
import { Switch, Redirect } from 'react-router'
import Login from './pages/Login'
import Vocabulary from './pages/Vocabulary'
const appContainer = document.getElementById('app')
ReactDOM.render(
<Router>
<div>
<ul>
<li><Link to="/">Home</Link></li>
<li><Link to="/vocabulary">Vocabulary</Link></li>
</ul>
<Switch>
<Route exact path="/" component={Login} />
<Route exact path="/vocabulary" component={Vocabulary} />
</Switch>
</div>
</Router>,
appContainer)
Run Code Online (Sandbox Code Playgroud) 我愿意为我的应用程序使用React-router,我正在尝试首先在doc中给出的示例,我在下面复制了它.现在,当我去localhost:3000/
,我看到"App"按预期,但每隔一页,如localhost:3000/inbox
返回"无法获取/收件箱".我在这里错过了什么?
var About = React.createClass({
render: function () {
return <h2>About</h2>;
}});
var Inbox = React.createClass({
render: function () {
return <h2>Inbox</h2>;
}});
var App = React.createClass({
render () {
return (
<div><h1>App</h1>
<RouteHandler/>
</div>
)}});
var routes = (
<Route path='/' handler={App}>
<Route path="about" handler={About}/>
<Route path="inbox" handler={Inbox}/>
</Route>
);
Run Code Online (Sandbox Code Playgroud) 我是新手,reactjs
我有一个小项目reactjs
可以玩并学习它.我需要输入基于url路径显示的标题类型.所以以下是我的index.js处理路由:
const history = useRouterHistory(createHistory)({
basename: '/test'
})
class Tj extends React.Component {
render() {
return (
<Router history={history}>
<Route path={"/"} component={Bridge} >
<IndexRoute component={Home} />
<Route path={"user"} component={T} />
<Route path={"home"} component={Home} />
</Route>
<Route path={"/t/"} component={Bridge2} >
<IndexRoute component={T} />
<Route path={"contact"} component={Home} />
</Route>
</Router>
);
}
}
render(
<Provider store={store}>
<Tj/>
</Provider>,
window.document.getElementById('mainContainer'));
Run Code Online (Sandbox Code Playgroud)
正如您所看到的,我使用test作为根目录,并根据用户的url输入决定我应该使用哪个头.这里还有Bridge2.js:
export class Bridge2 extends React.Component {
render() {
return (
<div>
<div className="row">
<Header2/> …
Run Code Online (Sandbox Code Playgroud) 我正在使用React-Router 1.0.0-rc3和Redux-Router 1.0.0-beta3.
使用React-Router时,您可以使用useBasename
with createHistory
来设置应用程序的基本URL,以便您可以轻松编写在子目录中运行的应用程序.示例:
而不是这个:
import { createHistory } from 'history';
let base = "/app_name/"
<Router history={browserHistory}>
<Route path={base} component={App}></Route>
</Router>
<Link path={base + "some_path"}>some_path</Link>
Run Code Online (Sandbox Code Playgroud)
您可以使用以下方式编写useBasename
:
import { createHistory, useBasename } from 'history';
const browserHistory = useBasename(createHistory)({
basename: "/app_name"
});
<Router history={browserHistory}>
<Route path="/" component={App}></Route>
</Router>
<Link path="/some_path">some_path</Link>
Run Code Online (Sandbox Code Playgroud)
但是,在Redux-Router中,您需要传递createHistory
而不是history
减速器:
const store = compose(
applyMiddleware(m1, m2, m3),
reduxReactRouter({
routes,
createHistory
}),
devTools()
)(createStore)(reducer);
Run Code Online (Sandbox Code Playgroud)
useBasename
在这种情况下我们如何使用?
我已按照此处列出的步骤(https://pages.github.com/)为我正在处理的网站设置了GitHub页面
我设置的站点当前托管在IIS下,并使用URL Rewrite模块.
是否有一个等效的模块或类似的东西,我可以用来重写我的应用程序中的某些URL请求?
我在apache服务器上托管我的vuejs项目.
const router = new VueRouter({
routes: Routes,
// relative: true,
mode: 'history'
});
Run Code Online (Sandbox Code Playgroud)
这在本地运行良好,但vue路由器在服务器上中断.例
如果我运行http://example.com并转到http://exmaple.com/sub 它工作正常
但如果我刷新页面它会抛出404错误.
我没有找到这个问题的解决方案,但我已经尝试了各种解决方案,但没有任何效果。我有一个 React JS 应用程序,当部署在测试服务器上并且您在页面上点击刷新时,我收到 404 错误消息。我尝试过 URL 重写,这有助于导航回主页,但这并不能解决刷新问题。请帮忙。
reactjs ×6
react-router ×5
apache ×2
javascript ×2
.htaccess ×1
firebase ×1
github ×1
github-pages ×1
localhost ×1
redux ×1
routes ×1
vue-router ×1
vue.js ×1
vuejs2 ×1