为什么我的构建项目Angular2不能在任何apache服务器上运行?

时间:2017-04-14 10:57:37

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

我在mac OS Sierra的本地服务器apache中转向我的构建角度项目(用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

使用的版本:

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

3 个答案:

答案 0 :(得分:0)

缺少有效的基础href,请确保index.html包含

  <base href=".">

答案 1 :(得分:0)

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

我认为这不符合逻辑,因为在Ubuntu中使用默认基数href =&#34; /&#34; Old index.html generted with build and work correct in Ubuntu

答案 2 :(得分:0)

解决了我:

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