AngularJS: How to remove #!/ (bang prefix) from URL?

后端 未结 6 1366
不思量自难忘°
不思量自难忘° 2020-12-03 15:29

I already have done $locationProvider.html5Mode(true); but it is not working. Whenever I access http://example.com it goes to http://example.

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-03 16:12

    If you are in .NET stack with MVC with AngularJS, this is what you have to do to remove the '#' from url:

    1.Set up your base href in your _Layout page:

       
    

    2.Then, add following in your angular app config :

    $locationProvider.html5Mode(true)
    $locationProvider.hashPrefix("!");
    

提交回复
热议问题