【问题标题】:showing 404 error file not found in GitHub publish when come back to my project返回我的项目时显示 GitHub 发布中未找到 404 错误文件
【发布时间】:2020-03-18 05:18:58
【问题描述】:

当我上传到 GitHub 并成功发布时,我有一个简单的静态 Web 应用程序,它在现场显示,但问题是,当我单击外部链接并再次使用 chrome 的后退箭头返回时它像这样向我展示,并假设在我的应用程序中我提到了像 <a href="https://facebook.com"></a> 这样的链接,然后返回错误显示如下,您可以检查以下错误。

404
File not found

The site configured at this address does not contain the requested file.

If this is your site, make sure that the filename case matches the URL.
For root URLs (like http://example.com/) you must provide an index.html file.

这是我在 GitHub 上的 Dist 文件夹,你可以看到 index.html 在那里,然后它也显示错误 404 文件未找到。

我更喜欢这个解决方案,但不适合我,这是Link,我发现了很多资源但没有工作。

【问题讨论】:

    标签: github angular6 http-status-code-404 publish file-not-found


    【解决方案1】:

    我从双方都尝试过,首先我尝试使用不工作的 GUI,然后使用 CLI 工作正常,首先不要从 GUI 发布使用CLI,因为我们不需要手动上传 dist 文件和对于 dist 文件,我们将使用其他命令制作 dist 文件,并将 dist 文件直接上传到 GitHub。

    还有一件事是不要像username.github.io 这样创建存储库,创建一个名称简单的存储库,如 test 或 sample 随便你。

    要部署您的 Angular 应用程序,首先在 GitHub 上创建一个存储库。为此,导航至https://github.com/,然后单击新建存储库。我正在创建一个名为“testing”的存储库

    当你遇到类似'git' is not recognized as an internal or external command, operable program or batch file.这样的错误时,在执行以下步骤之前

    那你需要安装 git form Here

    仓库创建完成后,使用git命令将该仓库作为远程文件添加到本地项目中。为此,请运行以下命令:

    git remote add origin https://github.com/USERNAME/PROJECT_NAME.git
    

    不要忘记更改用户名和项目名称。添加远程存储库后,您可以使用以下命令进行验证:

    git remote -v
    

    你会得到仓库列表

    要将 Angular 应用程序部署到 GitHub,您需要首先全局安装 angular-cli-ghpages:

    npm install -g angular-cli-ghpages
    

    安装ghpages后,使用Angular CLI构建项目。为此,请运行如下所示的命令:

    ng build --prod --base-href https://<username>.github.io/testing/
    

    最后一步,运行命令ngh -no-silent发布应用程序

    成功发布您的应用后,导航至https://&lt;username&gt;.github.io/&lt;testing&gt;/ 以在 GitHub 上查看它。这就是将 Angular 应用程序部署到 GitHub 所需要做的一切。

    或

    您将在存储库设置下获得发布链接,只需向下滚动至github pages。

    【讨论】:

      猜你喜欢
      • 2020-12-18
      • 1970-01-01
      • 2021-02-05
      • 2014-02-11
      • 1970-01-01
      • 1970-01-01
      • 2021-03-31
      • 1970-01-01
      • 2019-04-18
      相关资源
      最近更新 更多