javascripthtmlangularjsbase-tag

AngularJS - Configure multiple base tags


When using angularjs, there is the # that needs to be removed. To accomplish that you need to set the following:

$locationProvider.html5Mode(true);

and also add the base tag so when the page refreshes it works normally. The point is if it's defined as <base href="http://example.com/"> then it only works from this url. i.e I can not access the website from www.example.com.

So is there a way to configure some sort of multiple base so that when one fails, it gets replaced with the other?


Solution

  • <base href="/"></base> - for ROOT webapps.

    <base href="/webappName/"></base> - for non ROOT webapps.

    Also, you only need to use the the <base> tag if you have relative <a> tags.