AngularJS - Configure multiple base tags

395 Views Asked by At

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?

2

There are 2 best solutions below

0
Daniel On BEST ANSWER

<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.

0
Eduardo Pereira On

You can use:

<base href="/">

Or if you don't want to use base:

$locationProvider.html5Mode({ enabled: true, requireBase: false });