Skip to content

Commit fe0fa67

Browse files
docs: easier Netlify setup for history mode (#6093)
Co-authored-by: Haoqun Jiang <[email protected]>
1 parent 9e32481 commit fe0fa67

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

docs/guide/deployment.md

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,15 +169,31 @@ Commit both the `.gitlab-ci.yml` and `vue.config.js` files before pushing to you
169169
170170
Also checkout [vue-cli-plugin-netlify-lambda](https://github.com/netlify/vue-cli-plugin-netlify-lambda).
171171
172-
In order to receive direct hits using `history mode` on Vue Router, you need to create a file called `_redirects` under `/public` with the following content:
172+
#### Use history mode on Vue Router
173+
174+
In order to receive direct hits using `history mode` on Vue Router, you need to redirect all trafic to the `/index.html` file.
175+
176+
> More information on [Netlify redirects documentation](https://docs.netlify.com/routing/redirects/rewrites-proxies/#history-pushstate-and-single-page-apps).
177+
178+
##### Recomended method
179+
180+
Create a file called `netlify.toml` in the root fo your repository wit the following content:
181+
182+
```toml
183+
[[redirects]]
184+
from = "/*"
185+
to = "/index.html"
186+
status = 200
187+
```
188+
189+
##### Alternative method
190+
Create a file called `_redirects` under `/public` with the following content:
173191
174192
```
175193
# Netlify settings for single-page application
176194
/* /index.html 200
177195
```
178196
179-
More information on [Netlify redirects documentation](https://www.netlify.com/docs/redirects/#history-pushstate-and-single-page-apps).
180-
181197
If you are using [@vue/cli-plugin-pwa](https://cli.vuejs.org/core-plugins/pwa.html#vue-cli-plugin-pwa) make sure to exclude the `_redirects` file from being cached by the service worker.
182198
To do so, add the following to your `vue.config.js`:
183199
```javascript

0 commit comments

Comments
 (0)