【发布时间】:2020-03-26 16:38:17
【问题描述】:
我有 yii2+vue 项目,它运行良好,除了子 url 首先从 404 重定向。 我的 htaccess 文件如下所示:
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
Vue 路由器:
router.beforeEach((to, from, next) => {
store.dispatch('auth/check')
.then(res => {
console.log(res);
if (to.path == '/login' && res.status) {
next('/')
} else if (!to.meta.guest && !res.status) {
next('/login')
} else {
next()
}
}, () => {
})
})
当我访问任何子页面时,例如http://domain/subpage,它首先显示 404 apache 页面..然后重定向到 vue 管理的内容页面。请帮忙
【问题讨论】:
标签: apache vue.js yii2 router history