title: Angularjs getting clean url returns url undefined error
body: <p>I am trying to get clean urls using <code>$locationProvider.html5Mode(true)</code> gives </p>
  
  <pre><code>TypeError: Cannot read property 'replace' of undefined. 
  </code></pre>
  
  <p>The application uses <code>$stateProvider</code> for routing.</p>
  
  <p>I also have the base url defined in <code>&lt;head&gt;</code></p>
  
  <pre><code>&lt;base href="/"&gt;
  </code></pre>
  
  <p>From anglularjs lib:</p>
  
  <pre><code>function trimEmptyHash(url) {
    return url.replace(/(#.+)|#$/, '$1');
  }
  </code></pre>
  
  <p>url passed to this function is empty. Anyone knows a workaround.
  This is my app config:</p>
  
  <pre><code>wgApp.config(function($stateProvider, $urlRouterProvider, $locationProvider) {
    $locationProvider.html5Mode(true).hashPrefix('!')
  
    // Now set up the states
    $stateProvider
      .state('main', {
        url: "/main",
        cache: false,
        templateUrl: "/web-master/main.html"
      })
      .state('login', {
        url: "/login",
        templateUrl: "/web-master/main.html"
      })
  
     $urlRouterProvider.otherwise("/login");
   })
  </code></pre>