When I build my Vue project using hash router mode it works perfectly, but when I build it using history mode, it only shows the navbar and commented the <router-view>
. I have also configured my apache settings for history mode.
router.js
import { createRouter, createWebHistory } from 'vue-router'
import Home from '@/views/Home'
const routes = [
{
path: '/',
name: 'Home',
component: Home
},
]
const router = createRouter({
history: createWebHistory(process.env.BASE_URL),
routes
})
export default router
App.vue
<template>
<Navbar />
<router-view />
</template>
<script>
import Navbar from "@/components/Navbar";
export default {
components: { Navbar },
};
</script>
I could replace the <router-view>
on my app.vue with the Home view component directly, it would work. But that defeats the point of using vue router ovbiously. Help me please guys!
Also, here is the server config, I'm using apache and deploying it on a subdirectory called v2
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /v2/
RewriteRule ^v2/index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . v2/index.html [L]
</IfModule>