首页 > 解决方案 > 将 Angular 应用程序部署到 Apache 服务器子域

问题描述

我正在尝试将我的 Angular 9 应用程序部署到子域级别的 Apache 服务器,但我被卡住了。我不知道如何配置我的服务器和/或 .htaccess 文件以使 ngapp.domain.nl 服务于 Angular index.html 文件。

到目前为止采取的步骤:

RewriteEngine On
# If an existing asset or directory is requested go to it as it is
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -f [OR]
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_URI} -d
RewriteRule ^ - [L]

# If the requested resource doesn't exist, use index.html
RewriteRule ^ /index.html

但是,.htaccess 代码没有为子域配置,但我不知道如何更改此代码以使其适合。我也不知道我是否将 .htaccess 文件放在了正确的文件夹中。

此外,我不确定我的 DNS 设置是否符合预期。

子域行为原样

当我访问我的子域 - ngapp.domain.nl - 它显示一个默认页面(由我的托管服务提供商创建),表明子域已被占用。它为我放置在我的域前面的每个子域执行此操作。

任何帮助,将不胜感激 :)

编辑:添加到文件夹结构图像的链接

标签: angularapache.htaccesssubdomain

解决方案


修复:删除了 /ngapp/ 子域文件夹中的自动生成的 index.php。

这个 index.php 被加载而不是我的 index.html。index.php 加载了默认的提供程序页面。其他一切都设置正确。


推荐阅读