Adding Values to Header Drupal 7 + .htaccess
There is something you can try with Drupal itself. 

hook_url_inbound_alter


  Alters inbound URL requests.


The idea is to drupal_lookup_path and if nothing found you can do whatever with $path variable in  hook_url_inbound_alter