My 5th book "50 Tips on JavaScript" is on sale. Go get it from
Illustrated guide to 50 of the most interesting JavaScript topics.

Apache .htaccess for HTML5 push state manipulations

This is a quick post so I document my two hours research. I'm working on a open source library for routing in the browser. Or in other words JavaScript library that uses the history API. The thing is that locally I'm using Apache as a dev server and I wanted all the request to specific folder to be redirected to index.html.

What I meant is the following:

In order to do the routing entirely in the browser I needed all the child routes to be forwarded to the same index.html file. The .htaccess file that I ended up with is as follows:

  Options +FollowSymLinks
  IndexIgnore */*
  RewriteEngine On
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule (.*) index.html

I found the solution here

If you enjoy this post, share it on Twitter, Facebook or LinkedIn. To leave a comment go here.