Configure history.pushState for Angular 2
<p>My Angular 2 application uses the default <a href="https://developer.mozilla.org/en-US/docs/Web/API/History_API#Adding_and_modifying_history_entries" rel="nofollow noreferrer">HTML 5 <code>history.pushState</code></a> <a href="https://angular.io/docs/ts/latest/guide/router.html#!#browser-url-styles" rel="nofollow noreferrer">location strategy</a>. How do I configure a server with <code>history.pushState</code> so browser refreshes and browser URLs do not generate <code>404</code>s?</p>

<p>For example, the <a href="http://embed.plnkr.co/71VEirn2WzveVVMuHGp5/" rel="nofollow noreferrer">Tour of Heroes</a> application has a few different application routes like:</p>

<pre><code>http://localhost:8080/dashboard
http://localhost:8080/heroes
http://localhost:8080/detail/13
</code></pre>

<p>If you hit refresh on one of these routes, or type one of the URLs, you'll get <code>404</code> since <code>/detail/13</code> is an application route, not a server resource. I've configured the location strategy at the top of the <code>head</code> in my <code>index.html</code>:</p>

<pre><code>&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
  &lt;base href="/"&gt;
  &lt;meta charset="utf-8"&gt;
  &lt;title&gt;Tour of Heroes&lt;/title&gt;
</code></pre>

<p>but how should a server be configured so it sends all URLs to my application instead of generating a <code>404</code>?</p>

<p><strong>Note</strong>:
This question is the complement to the questions <a href="https://stackoverflow.com/questions/35284988/angular-2-404-error-occur-when-i-refresh-through-browser">Angular 2 : 404 error occur when i refresh through Browser</a> and <a href="https://stackoverflow.com/questions/31415052/angular-2-0-router-not-working-on-reloading-the-browser/31457808#31457808">Angular 2.0 router not working on reloading the browser</a> asking <strong>how</strong> to address this problem. For Firebase, there's this: <a href="https://stackoverflow.com/questions/34415725/when-i-refresh-my-website-i-get-a-404-this-is-with-angular2-and-firebase/">When I refresh my website I get a 404. This is with Angular2 and firebase</a> and for Apache there's this: <a href="https://stackoverflow.com/questions/22739455/htaccess-redirect-for-angular-routes">htaccess redirect for Angular routes</a>.</p>