title: htaccess 301 Redirect only if query string is present
body: <p>Is it possible to include a redirect (best would be a 301 redirect) to an external domain only if a query string is present?</p>
  
  <pre><code>Example:
  domain.com =&gt; domain.com
  domain.com?query-string =&gt; another-domain.com?query-string
  </code></pre>
  
  <p>Thank you very much!</p>
  
  <p>@anubhava Thank you very much for your help. 
  Now I have some additional conditions I would like to add:</p>
  
  <pre><code>first-domain.com =&gt; https://www.first-domain.com
  www.first-domain.com =&gt; https://www.first-domain.com
  http://first-domain.com =&gt; https://www.first-domain.com
  
  first-domain.com?query-string =&gt; https://www.another-domain.com/first-domain/?query-string
  www.first-domain.com?query-string =&gt; https://www.another-domain.com/first-domain/?query-string
  http://first-domain.com?query-string =&gt; https://www.another-domain.com/first-domain/?query-string
  https://www.first-domain.com?query-string =&gt; https://www.another-domain.com/first-domain/?query-string
  
  second-domain.com?query-string =&gt; https://www.another-domain.com/second-domain/?query-string
  www.second-domain.com?query-string =&gt; https://www.another-domain.com/second-domain/?query-string
  http://second-domain.com?query-string =&gt; https://www.another-domain.com/second-domain/?query-string
  https://www.second-domain.com?query-string =&gt; https://www.another-domain.com/second-domain/?query-string
  
  </code></pre>