【问题标题】:Why do we need mod_rewrite module when using AngularJS with Apache 2?为什么我们在使用 AngularJS 和 Apache 2 时需要 mod_rewrite 模块?
【发布时间】:2014-12-16 20:03:25
【问题描述】:

我正在尝试让 AngularJS 与 Apache 2 HTTP Server 一起工作。我在网上找到建议更改 .htaccess 以使用 mod_rewrite 模块(rewrite rules for apache 2 to use with angular js> 和Apache rewrite rules not being applied for angularjs>)的资源。

答案可能在于 Angular 和 Apache 如何工作的理论,但为什么需要一个用于 URL 重写(mod_rewrite)的模块才能让 Angular 在 Apache 上工作?我认为 Angular 是一个 JavaScript 框架,并且 JavaScript 在客户端上运行。即使包含 Angular 的 HTML 页面需要在提供给客户端之前进行翻译,URL 重写模块在此翻译中起什么作用?

谢谢。

【问题讨论】:

    标签: angularjs apache .htaccess mod-rewrite


    【解决方案1】:

    并非在每种情况下都需要重写 URL(就像我的情况一样)。我的问题是我使用的是 IE,它是在兼容模式下启动的。

    在我的 HTML 中使用了 What does <meta http-equiv="X-UA-Compatible" content="IE=edge"> do?> 处指定的行,它对我有用。

    【讨论】:

      猜你喜欢
      • 2013-08-04
      • 1970-01-01
      • 1970-01-01
      • 2017-05-03
      • 1970-01-01
      • 2023-04-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多