title: How to properly return 404 in angular JS with dynamic urls (slugs) and ng-include?
body: <p>I'm currently building a portfolio site for our company in AngularJS with UI-router. We're using the HTML5 url scheme, and I've got the standard .htaccess in place to rewrite requests to index.html ( though in production this will be running on a .NET server ).</p>
  
  <p>Some sections of the site are made up of freeform html documents rendered via ng-include directives, to allow our developers and designers the maximum freedom to create some pages however they want - for example client case studies that may warrant quite different layouts and media.</p>
  
  <p>The pages are all loaded via a slug parameter to a state, something like '/work/some-case-study-name'. The state handler then takes the slug parameter and supplies that as url to an html file for the ng-include to load. For example the url above would resolve to '/partials/case-studies/some-case-study-name.html'. This is all loaded into a  directive.</p>
  
  <p>At the moment, it seems to be impossible to catch a mis-typed slug url though. It appears that either through the .htaccess setup or angular's routing system, when ng-include fails to find the requested html file, it always returns 200OK and just renders the route of the site. </p>
  
  <p>Does anyone know of a way to make ng-include return a 404 if the document it's trying to load does not exist? </p>
  
  <p>thanks!</p>