RewriteCond %{QUERY_STRING} ^ref= [OR]
RewriteCond %{QUERY_STRING} ^referrer=
RewriteRule ^(.*)$ $1? [R=301,L]
Here’s the simplest solution, which I just tested...
You’ll need to add that before the MODx RewriteCond’s and RewriteRule. Obviously, you could extend that to deal with any troublesome query strings...
The secret is the ? at the end of the RewriteRule’s substitution string.