AngularJS 1.1.5 - automatically adding hash tag to URLs

Kevin Beal picture Kevin Beal · Jun 27, 2013 · Viewed 13.2k times · Source

Does anyone know why version 1.1.5 automatically adds a hashtag to your urls, and how to turn this off? IMO this is ugly looking. It happens whenever you have a url that doesn't end in a forward slash. (I'm not using routes or anything like that).

So this:

http://my.website.com/about

becomes

http://my.website.com/about#/about

and this:

http://my.website.com/about.html

becomes:

http://my.website.com/about.html#/about.html

but this:

http://my.website.com/about/

doesn't have this problem.

Answer

EnigmaRM picture EnigmaRM · Aug 21, 2013

I experienced this issue just the other day. I solved it by enabling HTML5 mode for $locationProvider. See Docs for $location - HTML5 Mode Updated link for $location - HTML5 Mode.

It should look similar to this:

.config(['$locationProvider', function($locationProvider){
    $locationProvider.html5Mode(true).hashPrefix('!');
}]);