我正在尝试使用 Nuxt.js 创建一个 SSG 网站。
当我访问 nuxt.config.js 的生成属性中未设置的路由时,
我想在不更改URL的情况下显示404页面的内容。(使用htaccess)
以下是正在建设中的现场
http://we-are-sober.d3v-svr.com/xxxx http://we-are-sober.d3v-svr.com/xxxx
这按预期工作。
http://we-are-sober.d3v-svr.com/user/xxxx http://we-are-sober.d3v-svr.com/user/xxxx
这不能按预期工作。
404页面的内容显示了一会儿,但很快就执行了基于“user/_id.vue”动态路由的流程。
问题的关键在于,不存在的路由表现得就像它存在一样。
有谁知道如何解决这个问题?
这是源代码。https://github.com/yhirochick/rewrite_test https://github.com/yhirochick/rewrite_test
404.vue
https://github.com/yhirochick/rewrite_test/blob/master/pages/404.vue https://github.com/yhirochick/rewrite_test/blob/master/pages/404.vue
用户/_id.vue
https://github.com/yhirochick/rewrite_test/blob/master/pages/user/_id.vue https://github.com/yhirochick/rewrite_test/blob/master/pages/user/_id.vue
nuxt.config.js
https://github.com/yhirochick/rewrite_test/blob/master/nuxt.config.js#L43-L45 https://github.com/yhirochick/rewrite_test/blob/master/nuxt.config.js#L43-L45
.htaccess
https://github.com/yhirochick/rewrite_test/blob/master/static/.htaccess https://github.com/yhirochick/rewrite_test/blob/master/static/.htaccess
我是日本人。以上文字基于谷歌翻译。
可能有点难以理解,不过还是谢谢你。