Süleyman Tekin
Süleyman Tekin

Reputation: 23

http://localhost:3000/#!/ why do I get "#!/" in my localhost link.

I am using Angularjs to build a web app but I am getting http://localhost:3000/#!/ instead of http://localhost:3000/ when I go to my index page.

I couldn't figure out why it's happening.

Some help would be great.

Upvotes: 2

Views: 878

Answers (1)

Bala Abhinav
Bala Abhinav

Reputation: 1348

The hashBang #! is usually added by angularjs between the url and the angular routes. You can disable it in the .config() using $locationProvider and setting the html5Mode to true like so :

.config('$locationProvider', function($locationProvider){
    $locationProvider.html5Mode(true);
})

Using HTML5 mode requires URL rewriting on server side, basically you have to rewrite all your links to entry point of your application (e.g. index.html). Requiring a <base> tag is also important for this case, as it allows AngularJS to differentiate between the part of the url that is the application base and the path that should be handled by the application. For more information, see AngularJS Developer Guide - HTML5 Mode Server Side.

Upvotes: 5

Related Questions