如何摆脱AngularJS站点URL中的哈希标记?

1 dns cname github angularjs github-pages

我将AngularJS站点上传到我的gh-pages分支机构,并将DNS A记录指向204.232.175.78.现在该网站已上线,但我看到一个哈希标记作为URL结构的一部分.以下是可以在网站主页上看到的两个网址

http://www.maxmythic.com/#/

http://siddhion.github.io/maxmythic_angular/#/

我希望访问者在地址栏中输入和查看的URL是简单的maxmythic.com.如果进入maxmythic.com,它会重定向到http://www.maxmythic.com/#/.

如何在没有www的情况下将主页的URL设置为maxmythic.com .尾随/#/

sri*_*arg 6

在应用程序的主模块的配置功能中,使用该html5mode()功能$locationProvider.阅读这些文档以获取更多信息:http://docs.angularjs.org/api/ng.$locationProviderhttp://docs.angularjs.org/guide/dev_guide.services.$location.

例:

angular.module('myApp', []).
  config(function($locationProvider) {
    $locationProvider.html5Mode(true);
  });
Run Code Online (Sandbox Code Playgroud)