如何将angular5应用程序部署到子目录

Man*_*ush 6 production-environment angular ng-build

我的角度应用程序托管在服务器中,其中应用程序URL为http://xyz.domain.in(示例网址)。现在,我在其中创建了子目录来托管另一个应用程序。但是,当我尝试访问类似http://xyz.domain.in/subfolder的路径时,请在控制台中获取它。

错误:无法匹配任何路线。网址段:“子文件夹”

子文件夹中的应用程序的基本href是

<base href="./subfolder">
Run Code Online (Sandbox Code Playgroud)

如何做到这一点?

Art*_*ory 15

启动构建时,必须指定子文件夹的路径:

ng build --base-href=/subfolder/
Run Code Online (Sandbox Code Playgroud)

  • 您是救生员! (2认同)

小智 10

不需要提及子文件夹名称,如果您在子文件夹中进行解聚,则只需提及 href="./"


Eli*_*hen 0

您需要pathMatch像这样添加到您的路线中:

{path: 'url', component: YourComponent, pathMatch: 'subfolder'},
Run Code Online (Sandbox Code Playgroud)