Look at the cPanel code then never do anything that looks like that ever again. :) It produces some of the worst code on the planet.
You'll need a RewriteCond to look at the requested query string and a RewriteRule looking at the requested path. There's many previous threads with example code as it's a question that comes up several times per week.
In the rule target NOTHING needs to be escaped and the quotes should be removed.
Use example.com in this forum to supress the auto-linking function.