title: How do I enable deep linking from address bar in a Nodejs + AngularJS solution
body: <p>So I set up a simple NodeJS + ExpressJS server taking care of routing and delivering content for an AngularJS application. It works fine and routing works, but only from within the app. If I type anything in the address bar home.html gets served - which makes sense, since I defined (routing in Node) that anything other than partials should serve home.html. </p>
  
  <p>But how do I make deep linking work then?</p>
  
  <p>When I type in localhost:3000/registrations, localhost:3000/forms gets served. However if I create a link on a page and link to localhost:3000/registrations it works. Also if I type in localhost:3000/registrations in the address bar localhost:3000/forms is served.</p>
  
  <p><strong>NodeJS+Express server</strong></p>
  
  <pre><code>var express = require('express');
  var app = express();
  
  //Set up static directory for serving static html
  app.use(express.static(__dirname + '/public'));
  
  app.get('/', function(req, res) {
    res.sendFile(__dirname + '/views/home.html');
  });
  
  app.get('/partials/:name', function (req, res) {
    var name = req.params.name;
    res.sendFile(__dirname + '/views/partials/' + name);
  });
  
  app.get('*', function(req, res) {
    res.redirect('/');
  });
  
  //Start server
  app.listen(3000);
  console.log('Server startet on port 3000');
  </code></pre>
  
  <p><strong>AngularJS app and controller - app.js</strong></p>
  
  <pre><code>var app = angular.module('regApp', [
    'ngRoute'
  ])
  .config(['$routeProvider','$locationProvider', function ($routeProvider, $locationProvider) {
    $locationProvider.html5Mode(true);
    $routeProvider.
      when('/form/:id', {
          templateUrl: 'partials/form.html',
          controller: 'FormCtrl'
        }).
      when('/forms', {
          templateUrl: 'partials/forms.html',
          controller: 'FormsCtrl'
        }).
      when('/registrations', {
          templateUrl: 'partials/registrations.html',
          controller: 'GridCtrl'
        }).
      otherwise( { redirectTo: "/forms" });
    }]);
  </code></pre>
  
  <p><strong>Main html - home.html</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html ng-app="regApp"&gt;
  &lt;head lang="en"&gt;
    &lt;meta charset="UTF-8"&gt;
    &lt;base href='/'&gt;
    &lt;title&gt;Registration app&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div class="jumbotron text-center"&gt;
      &lt;h1&gt;RegistrationApp&lt;/h1&gt;
    &lt;/div&gt;
  
    &lt;div class="container"&gt;
      &lt;div ng-view&gt;&lt;/div&gt;
    &lt;/div&gt;
  
    &lt;script src="/vendor/angular/angular.min.js"&gt;&lt;/script&gt;
    &lt;script src="/vendor/angular-route/angular-route.min.js"&gt;&lt;/script&gt;
    &lt;script src="/js/app.js"&gt;&lt;/script&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>