1<Switch>
2 <Route path="/" exact component={Home}/>
3 <Route path="/about" component={About}/>
4 <Route component={Page404} />
5</Switch>
1import React from 'react';
2import { render } from 'react-dom';
3import { BrowserRouter as Router, Route, Switch } from 'react-router-dom';
4
5import Hello from './Hello';
6import NotFound from './NotFound';
7
8const App = () => (
9 <Router>
10 <Switch>
11 <Route exact path="/" component={Hello} />
12 <Route component={NotFound} />
13 </Switch>
14 </Router>
15);
16
17render(<App />, document.getElementById('root'));
18
19
1<IfModule mod_rewrite.c>
2 RewriteEngine On
3 RewriteBase /
4 RewriteRule ^index\.html$ - [L]
5 RewriteCond %{REQUEST_FILENAME} !-f
6 RewriteCond %{REQUEST_FILENAME} !-d
7 RewriteCond %{REQUEST_FILENAME} !-l
8 RewriteRule . /index.html [L]
9</IfModule>
10