Search code examples
angular8hrefproduction-environment

How to access Angular 8 website without using base-href folder name in browser


I have angular 8 website which I build for production using following command:-

ng build --prod --configuration=production --base-href /eportal/*

I have created a folder "eportal" in hosting site and uploaded all components in the folder. It all worked fine and I can browse to the site using following url:-

www.abc.org/eportal/login

Is there any method or any command available in Angular 8 where I can keep my components in "eportal" folder in hosting site but access in this way(removing folder name):-

www.abc.org/login

Please help me on this.


Solution

  • First of all the —prod flag is an alias to —configuration=production. Please take advantage of this

    Coming to the question in particular, use the following command

    ng build —prod
    

    There should be assets generated in your dist/[app-name]/ folder.

    In your hosting site, instead of uploading those assets in the folder you created upload them outside.

    ie. You would have uploaded your assets in public_html/eportal instead of that upload them in public_html directly.