how to deploy angular5 application to sub directory

Manush picture Manush · Jun 22, 2018 · Viewed 7.9k times · Source

My angular application is hosted in server in which the application url is http://xyz.domain.in (Example Url). Now I created sub directory inside it to host another application. But when i try to access the path like http://xyz.domain.in/subfolder , getting this in console.

Error: Cannot match any routes. URL Segment: 'subfolder'

Base href of the application in subfolder is

<base href="./subfolder">

How to accomplish this?

Answer

Artory picture Artory · Jun 22, 2018

You have to specify the path of your subfolder when launching a build :

ng build --base-href=/subfolder/