diff --git a/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts b/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts index c8dd2dae78..b083eb2648 100644 --- a/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts +++ b/packages/@vuepress/core/src/app/prepare/preparePagesRoutes.ts @@ -27,10 +27,12 @@ ${app.pages // redirect from decoded path redirectsSet.add(decodeURI(path)) - // redirect from index path - if (/\/$/.test(path)) { - const indexPath = path + 'index.html' - redirectsSet.add(indexPath) + if (path.endsWith('/')) { + // redirect from index path + redirectsSet.add(path + 'index.html') + } else { + // redirect from the path that does not end with `.html` + redirectsSet.add(path.replace(/.html$/, '')) } // redirect from inferred path