Backbone.js + HTML5 PushState + Apache Virtual Host

If you're hosting a backbone.js app, where your backbone files are stored in:

  • /app/*
  • /dist/*
  • /vendor/*
  • /styles.min.css
  • /source.min.js
  • /index.html

Where all other web requests should be re-directed to index.html, then these mod_rewrite rules will probably come in handy:

<IfModule mod_rewrite.c>  
    RewriteEngine On
    RewriteRule ^/styles.min.css$ /styles.min.css [QSA,L]
    RewriteRule ^/source.min.js$  /source.min.js  [QSA,L]
    RewriteRule ^/(?!app|dist|vendor).*$ /index.html [QSA,L]
</IfModule>