title: htaccess redirect for Angular routes
body: <p>I have an angular application with several routes, such as:</p>
  
  <pre><code>site.com/
  site.com/page
  site.com/page/4
  </code></pre>
  
  <p>Using angular's html5 routing mode, these resolve correctly when you click links to them from within the application, but of course are 404 errors when you do a hard refresh. To fix this, I've tried implementing a basic htaccess rewrite.</p>
  
  <pre><code>RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_METHOD} !OPTIONS
  RewriteRule ^(.*)$ index.html [L]
  </code></pre>
  
  <p>This works for the angular requests, however when I try to load scripts or make ajax calls within my domain, such as:</p>
  
  <pre><code>&lt;script src="/app/programs/script.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>This script doesn't load - it's request is redirected and it tries to load the index.html page as the .htaccess thinks it should reroute the request - not knowing that this file does exist and it should load the file instead of redirect. </p>
  
  <p>Is there any way I can have the htaccess redirect the request to index.html (with the view parameters) only if there is not an actual file that it should resolve to?</p>