I tried setting an environment variable from the RewriteRule line in .htaccess as follows but it didn't seem to help and after the first load or two seems to have caused a 500 error (not quite sure why)...
RewriteRule !\.(js|ico|gif|jpg|png|css|pdf)$ index.php [E=REQUEST_URI:%{SCRIPT_URL}]
|