I would suggest a rewrite that directly serve the file, by escaping the "?" to "\%F3".
To serve files:
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^(.*)$ $1\%3F%{QUERY_STRING}? [L]
Do the same for folders (i.e. serve index.html - adapt index.html to fit your needs)
RewriteCond %{REQUEST_FILENAME} ^.*/$
RewriteCond %{QUERY_STRING} !=""
RewriteRule ^(.*)/$ $1/index.html\%3F%{QUERY_STRING}? [L]
First, we test if the file exists (see next paragraph about this), second we check that we have a query string (otherwise, serve the file as usual), then add the "?" and the original query string and serve it.
I add the "?" at the end, to erase the QueryString (since it is already handled), and to avoid the rule to be applied a second time (ex: if serving a file in a subdirectory). Other solution would be to use the "END" flag (see http://httpd.apache.org/docs/current/en/mod/mod_rewrite.html#rewriterule). According to the same page, and as mentionned by @csharkey and @Gavin C, [qsdiscard] could be added instead in apache 2.4:
RewriteRule ^(.*)/$ $1/index.html\%3F%{QUERY_STRING}? [L,qsdiscard]
Caveat: I didn't test this solution thouroughly, so errors may remains.
?
to separate arguments from the URI is the default behavior. How do you have apache configured now? And doesfilename.asp
exist in the directory you're shooting for?