Vue Routerを使ったサイトで404が発生してしまった
Vue Routerを使ったサイトで、いきなり途中のURLにジャンプしたり、$router.push(‘/xxx’)した後の表示でF5(リロード)したりしたら、404になってしまった。
vue-cliで開発中は問題なかったのに、buildしてapacheに配備したら404になった。
Not Found The requested URL /xxx was not found on this server. Apache Server at www.yamacoco.com Port 80
解決方法
ちゃんと公式ドキュメントに書かれていた。
mod_rewriteで対応するなら
<IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.html [L] </IfModule>
mod_dirが使えるのであれば
<IfModule mod_dir.c> FallbackResource /index.html </IfModule>
まとめ
動かす前にドキュメントは読まなくてはいけない。
同じタグの記事
- html data-* 属性
- javascriptの配列操作
- jjs
- jQueryで部分一致検索
- jqueryのバージョンとprop()
- jrunscript
- Template Engine Mustache を使う
- vue.jsでテンプレートが一瞬表示されてしまう
同じカテゴリの記事