title: Nginx rewrite rules for Angularjs to remove # hash in url in dynamic routes
body: <p>I have done the following:</p>
  
  <p><strong>AngularJS app</strong></p>
  
  <p>In app.js:</p>
  
  <p><code>$locationProvider.html5Mode(true);</code></p>
  
  <p>In index.html:</p>
  
  <p><code>&lt;base href="/"&gt;</code></p>
  
  <p><strong>nginx config</strong></p>
  
  <p><code>
  location / {
                  try_files $uri /index.html;
          }
  </code></p>
  
  <p>After deployment, things are working fine (# hash sign is removed) with the static pages. I can go directly to <code>http://fakeurl/about</code> or <code>http://fakeurl/download</code> pages; if I refresh the browser, the pages still load.</p>
  
  <p>However, when I go directly to a dynamic page:</p>
  
  <p><code>http://fakeurl/cars/:car_id</code></p>
  
  <p>Then nginx will serve 404.</p>
  
  <p>If I use the # path, then it redirects to the path without the # sign and displays the page; but when I refresh the page again, it shows 404. (This only happens with dynamic routes)</p>
  
  <p><code>http://fakeurl/#/cars/:car_id</code></p>
  
  <p><code>http://fakeurl/#/shops/:shop_id</code></p>
  
  <p>What rewrite rules do I need to write in the nginx blocks to serve my dynamic routes? Thanks!</p>