angular - 将 Angular 应用程序部署到 Apache 服务器子域
问题描述
我正在尝试将我的 Angular 9 应用程序部署到子域级别的 Apache 服务器,但我被卡住了。我不知道如何配置我的服务器和/或 .htaccess 文件以使 ngapp.domain.nl 服务于 Angular index.html 文件。
到目前为止采取的步骤:
- 我使用 构建我的 Angular 应用程序
ng build --prod
,生成一个分发文件夹 (dist/ngapp/) - 我使用主机提供商的控制面板创建了一个名为“ngapp”的子域。这导致创建了一个子域文件夹。此文件夹位于根/子域/ngapp。我将 /ngapp/ 分发文件夹中包含的所有内容都放在了其中。在此处查看文件夹结构的图像。
- 我按照Angular 文档中的描述配置了我的 .htaccess,并将它与我的分发文件一起放在我的 /ngapp/ 中。请参阅下面的代码。
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 - 它显示一个默认页面(由我的托管服务提供商创建),表明子域已被占用。它为我放置在我的域前面的每个子域执行此操作。
任何帮助,将不胜感激 :)
编辑:添加到文件夹结构图像的链接
解决方案
修复:删除了 /ngapp/ 子域文件夹中的自动生成的 index.php。
这个 index.php 被加载而不是我的 index.html。index.php 加载了默认的提供程序页面。其他一切都设置正确。
推荐阅读
- mongodb - 如何找到所有文件的单价*数量
- java - 在每个方法中不关闭 javax.sql.DataSource 可以吗?
- c# - Selenium - 发送密钥以在影子根(打开)和挪威银行 ID 的多个 iframe 中输入密码
- bootstrap-4 - 引导程序 4
- python - Tensorflow:创建一个对角矩阵,输入在子/超对角线上
- rust - 如何实现可能的突变的通用穿插
- javascript - Turf JS 交叉口问题
- kotlin - “this”不是 ArrayAdapter Kotlin 可接受的上下文
- javascript - React 'isSelected' 不适用于检查它是否被选中
- html - 行无排水沟不删除间距