在Apache Web服务器上部署Angular 4 App

问题描述:

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

I want to deploy my Angular Application on my Apache Webserver. I already added a .htaccess file to my /var/www/html folder, I tried several base-hrefs. But like many people I have problems with routing. I can only see my Startpage, but when I want to get to a other URL it fails. What else can I try or have I missed something?

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

You have to enable/install the Apache mod_rewrite module, and then put this in either your .htaccess or your apache configuration for your site:

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