AngularJS 没有#/home 的索引页

AngularJS index page without #/home

我有一个 AngularJS 1.0.7 网络应用程序。当我在浏览器中加载我的网站时,我输入 www.domainname.com。浏览器加载页面,我的浏览器 url 立即更改为 www.domainname/home.

如何避免这种情况?我希望浏览器在 index.html

时显示 www.domainname.com

更新:

请看我的app.js:

'use strict';


// Declare app level module which depends on filters, and services
angular.module('myApp', ['myApp.filters', 'myApp.services', 'myApp.directives', 'myApp.controllers'])
  .config(['$routeProvider', '$httpProvider', '$locationProvider',function($routeProvider, $httpProvider, $locationProvider) {

    // use the HTML5 History API
    $locationProvider.html5Mode(true);   

    $httpProvider.defaults.useXDomain = true;
    delete $httpProvider.defaults.headers.common["X-Requested-With"];           

    $routeProvider.when('/about', {templateUrl: 'partials/about.html', controller: 'AboutCtrl'});    
    $routeProvider.when('/contact', {templateUrl: 'partials/contact.html', controller: 'HomeCtrl'});
    // More routing
    $routeProvider.when('/home', {templateUrl: 'partials/home.html', controller: 'HomeCtrl'});
    // More routing
    $routeProvider.otherwise({redirectTo: '/home'}); 
  }])
  .config(function(AngularyticsProvider) {
    AngularyticsProvider.setEventHandlers(['Console', 'GoogleUniversal']);
  }).run(function(Angularytics) {
    Angularytics.init();
  });

如果你替换它应该可以工作:

$routeProvider.otherwise({redirectTo: '/home'});

来自

$routeProvider.otherwise({redirectTo: '/'});

并添加:

$routeProvider.when('/', {templateUrl: 'partials/home.html', controller: 'HomeCtrl'});

注意:正如@isherwood 在下面正确评论的那样:

$routeProvider.when('/home', {templateUrl: 'partials/home.html', controller: 'HomeCtrl'});

可以完全删除,以避免“/”和“/home”都指向同一路由。