I'm by using this rule:

RewriteRule !^(.*?/.*|.*?\.(?:php|html)$)$ headers.php?a=$1 [L]

(in line with the great contributions on http://stackoverflow.com/questions/3345747/regex-match-this-or-that)

It rewrites to headers.php after i type localhost/foo however the a variable is empty rather than foo (I checked with var_dump($_REQUEST))

Any idea why? I attempted using

RewriteCond  %{REQUEST_URI}  !headers

however it wasn't that.

Thanks!

The rule is negated, so it's performed if and only when the standard expression does not match the URI being processed. Because the taking group does not match localhost/foo, there is nothing for that regex engine to place into $1. The answer would be to avoid using negation inside your RewriteRule directive, and rather use RewriteCond directives to determine the negated regex. The next ruleset should work. (I've not test drive it, though. It is possible that you have a mistake somewhere.)

RewriteCond %{REQUEST_URI} !/.*/
RewriteCond %{REQUEST_URI} !\.(html|php)$
RewriteRule (.*) headers.php?a=$1 [L]