title: mod_rewrite to find missing /img/foo.jpg in /img/f/
body: <p>I've got a folder of images which is reaching a critical mass after a few years.</p>
  
  <p>I want to move images into alphabetical folders, so that <code>/img/foo.jpg</code> goes into <code>/img/f/foo.jpg</code> and <code>/img/bar.jpg</code> goes into <code>/img/b/bar.jpg</code> and so on.</p>
  
  <p>In order to make the transition smooth, and to allow the manual uploaders to put stuff into the top level, I'd like to use mod_rewrite to do this:</p>
  
  <ul>
  <li>if <code>/img/foo.jpg</code> exists, serve it
  up,  </li>
  <li>if not look for it in
  <code>/img/f/foo.jpg</code></li>
  </ul>
  
  <p>thanks for any suggestions.</p>
  
  <p>For the record, no, I don't think we need to go <code>/img/f/fo/foo.jpg</code> just yet. </p>