【问题标题】:Netlify: Page not found except index.htmlNetlify:找不到除 index.html 之外的页面
【发布时间】:2023-01-23 17:57:57
【问题描述】:

我在 Netlify 上部署了站点,然后它只显示 index.html,当我单击转到我网站中其他页面的链接时,它显示“找不到页面”, 我使用 vite 来运行和构建我的项目,以及用于 css 的 Tailwind

【问题讨论】:

  • 使用页面上的 href 链接检查您的站点文件夹结构
  • @HARISUMAID 我检查过它是正确的
  • 您可以尝试在本地构建并检查您的构建文件是否正确包含您的链接

标签: html css sass netlify vite


【解决方案1】:

如果您正在构建 SPA,您可能希望所有 URL 在处理路由逻辑之前都提供 index.html。这可以使用Netlify's File-based configuration file来完成。

避免 404
如果您的应用程序使用 history pushstate 来获取干净的 URL,则无论浏览器请求什么 URL,您都必须添加重写规则来提供 index.html 文件。

More info on Builds configuration


netlify.toml

[build]
  command = "vite build"
  publish = "dist"

[[redirects]]
  from = "/*"
  to = "/index.html"
  status = 200

【讨论】:

  • 不,它不是 SPA,仅使用 html 开发。
【解决方案2】:

“您似乎点击了损坏的链接或输入了本网站上不存在的 URL。” 这个错误让我头疼

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-12-15
    • 1970-01-01
    • 2020-12-28
    • 2020-07-07
    • 2016-06-07
    • 2011-07-08
    • 2018-05-07
    • 1970-01-01
    相关资源
    最近更新 更多