mallowigi
6/26/2014 - 8:21 AM

angular_html5_config.md

server {
  listen 80;
  set $host_path "/path/to/your/app";
  root $host_path;
  index index.html;

  # SEO
  if ($args ~ "_escaped_fragment_=/?(.+)") {
    set $path $1;
    rewrite ^ /snapshots/$path last;
  }
  
  # Re-route nested routes through index
  location / {
    try_files $uri $uri/ /index.html =404;
  }
}
...
<head>
<!--use absolute paths for file refs-->
<link rel="stylesheet" href="/styles/main.css">
...
<base href="/">
...
</head>
...
app.config(function (...) {
  $locationProvider.html5Mode(true);
  $locationProvider.hashPrefix = '!';
  ...
});

A Working configuration to setup HTML5 push-state routing in your AngularJS app with Nginx as your web server.