title: How to do both internal and external .htacces rewrite to completely remove ALL QUERY_STRING elements from ALL URIs, with relative path
body: <p>I want to remove all client request querystrings whatsoever, no exceptions.
  I have tried everything I can find, and everything I know about regular expressions, and this task puzzles me. I have been able to achieve removal of the query strings, but now all requests have the full file path prepended to the working directory upon rewrite and redirect.</p>
  
  <p>Examples: there is no http in these because stackoverflow won't let me post URLs.</p>
  
  <p>I access the file: /localhost/testing/dogs/pups.txt
  Yes, pups.txt exists and lives right there.</p>
  
  <p>Server returns this to browser: /localhost/home/user/public_html/testing/dogs/pups.txt</p>
  
  <p>If I access it with a query string appended:
  /localhost/testing/dogs/pups.txt?bark=woof</p>
  
  <p>I get the same output to the browser:
  /localhost/home/gost/public_html/testing/dogs/pups.txt</p>
  
  <p>So I know the query string is being nixed, while the full root path is being added to the hypertext address.</p>
  
  <p>How do I tell mod_rewrite to keep the relative path of the existing files, so that this prepending of the full file path stops, and accurately cause it to rewrite internally and externally so that no query string ever makes it to php-land?</p>
  
  <p>Here is the current .htaccess file. It resides in directory /home/user/public_html/testing. Where deployed online, it is NOT possible to put it in the root web directory, the obvious move that would instantly resolve this problem.</p>
  
  <pre><code># These are commented out on purpose because they kill access to the server.
      # The weird rules for regex in Apache configurations is baffling me. This
      # does remove all QUERY_STRING characters, but, it then rewrites by 
      # prepending the web root path to the current directory, causing error 404.
  
      # RewriteCond %{QUERY_STRING} ^
      # RewriteRule  (.*) $1? [R=301,L]
  
      # These rules work fine. Whatever does not end with a media or document
      # extension gets sent to index.php
  
      RewriteRule ^.*\.(gif|jpe?g|png|txt|svg|pdf|rtf|odt|doc|docx)$ - [L]
      RewriteRule ^.*\.(tex|epub|mobi|csv|ods|xls|swf|flv)$ - [L]
  
      RewriteRule ^ index.php [L]
  </code></pre>