我复制了 gatsby 构建提供给 ampps/www/my-site 的文件,但链接不起作用

I copy the files that the gatsby build gives to ampps/www/my-site but the links not work

我使用 gatsby-cli 创建了一个新站点。然后我只是构建站点,然后,我将 build 中的所有内容复制到我的 AMPPS/www/my-site 文件夹中。当我访问该站点时,索引工作正常,但是当我单击一条路线转到另一条路线时,出现以下错误:The requested URL /page-2/ was not found on this server..

我了解到 gatsby 会生成静态 HTML 站点,而我需要放置构建的生产服务器只接受静态 HTMl 站点。那么有没有办法用gatsby实现真正的服务端渲染呢?

提前致谢。

解决方法很简单:

如果 apache ampps/www/my-site 作为 http://localhost/my-site 服务,您需要使用路径前缀,默认情况下 gatsby 假设它将托管在域的根目录下。

要启用此功能,我们只需要使用以下文档:https://www.gatsbyjs.org/docs/path-prefix/