【问题标题】:Deploy Angular 4 App on Apache Webserver在 Apache Web 服务器上部署 Angular 4 应用程序
【发布时间】:2017-11-15 08:14:31
【问题描述】:

我想在我的 Apache Web 服务器上部署我的 Angular 应用程序。我已经在我的/var/www/html 文件夹中添加了一个.htaccess 文件,我尝试了几个base-href。但像许多人一样,我在路由方面遇到了问题。我只能看到我的起始页,但是当我想访问其他 URL 时它失败了。我还能尝试什么或者我错过了什么?

【问题讨论】:

  • 尝试将散列添加到您的 url 模式。看起来您的服务器设置不正确。 angular.io/guide/router#browser-url-styles
  • @Taha Obed,我们可以聊聊吗,我正在尝试做同样的事情,比如我想在 apache 服务器上部署 Angular 4 应用程序,我想知道其中的细节,我的 gmail是 theakshay.jain@gmail.com

标签: angular apache centos7


【解决方案1】:

您必须启用/安装 Apache mod_rewrite 模块,然后将其放入您的 .htaccess 或您网站的 apache 配置中:

<IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteBase /
  RewriteRule ^index\.html$ - [L]
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.html [L]
</IfModule>

【讨论】:

【解决方案2】:

在“/etc/apache2/httpd.conf”中取消注释这一行

#LoadModule rewrite_module libexec/apache2/mod_rewrite.so

LoadModule rewrite_module libexec/apache2/mod_rewrite.so

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多