Vue.js 找不到Vue js路由404和资源
我已将模式设置为历史记录:Vue.js 找不到Vue js路由404和资源,vue.js,vuejs2,Vue.js,Vuejs2,我已将模式设置为历史记录: const router = new VueRouter({ mode: 'history', routes:[ ... { path: '*', name: '404', components: { default: Page404}, } }) 创建htaccess <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^ind
const router = new VueRouter({
mode: 'history',
routes:[
...
{
path: '*',
name: '404',
components: { default: Page404},
}
})
创建htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.html [L]
</IfModule>
重新启动发动机
重写基/
重写规则^index\.html$-[L]
重写cond%{REQUEST_FILENAME}-F
重写cond%{REQUEST_FILENAME}-D
重写规则/index.html[L]
一切按预期运行错误的URL下降到404页。。。问题在于深层URL,例如website.com/error/error/error图像不会出现在404页面中 这与我缺少一个斜杠无关
/
这适用于一级url:
<img class="title" src="img/sad404.png" alt="404 not found" />
<img class="title" src="/img/sad404.png" alt="404 not found" />
这是正确的方法: