【问题标题】:Why my build project Angular2 don't work in any apache server?为什么我的构建项目 Angular2 不能在任何 apache 服务器上运行?
【发布时间】:2017-09-10 15:11:05
【问题描述】:

我在 mac OS Sierra 的本地服务器 apache 中打开了我的构建 angular 项目(使用 Webpack 弹出),我发现 index.html 中的资源文件存在问题,但是当我在 Ubuntu 项目中运行相同的构建时正确无误。

我在 mac OS Sierra 10.12.4 上的默认服务器 Apache 中运行构建项目: Result in mac OS Sierra 10.12.4 with default Apache (当我在macOS中使用MAMP PRO时,加载文件的状态是404)

当我在 Ubuntu 16.04 LTS 中运行相同的构建项目时: Result in Ubuntu 16.04 LTS with default Apache

使用的版本:

  • 角度:2.4.8
  • Angular CLI:1.0.0-rc.0
  • webpack:2.2.1

【问题讨论】:

  • 更改基础 href="."为你工作?

标签: angularjs apache webpack macos-sierra apache2.4


【解决方案1】:

它缺少一个有效的基本 href,确保 index.html 包含

  <base href=".">

【讨论】:

    【解决方案2】:

    好的,我更改我的 index.html: the result with base href="."

    我认为这是不合逻辑的,因为在 Ubuntu 中使用默认基本 href="/" 可以正常工作 Old index.html generted with build and work correct in Ubuntu

    【讨论】:

      【解决方案3】:

      这解决了我:

      https://medium.com/@JohnFoderaro/how-to-set-up-apache-in-macos-sierra-10-12-bca5a5dfffba 我的 apache2 配置中的问题不在基本 href 中

      【讨论】:

        猜你喜欢
        • 2021-03-13
        • 2019-12-18
        • 1970-01-01
        • 2019-12-19
        • 1970-01-01
        • 1970-01-01
        • 2011-05-27
        • 2016-03-18
        • 1970-01-01
        相关资源
        最近更新 更多