title: Apache VirtualHost redirect, change only domain
body: <p>How can I create VirtualHost to redirect all links changing only its domain, including subdomain and parameters:</p>
  
  <pre><code>exampleA.com -&gt; exampleB.com
  test.exampleA.com -&gt; test.exampleB.com
  test1234.exampleA.com/url/test.html?param=222 -&gt; test1234.exampleB.com/url/test.html?param=222
  </code></pre>
  
  <p>I want to redirect all subdomains like *, and it should be permanent 301</p>
  
  <p>Now I have a simple 301 redirection</p>
  
  <pre><code>&lt;VirtualHost *:80 *:443&gt;
          ServerName exampleA.com
          ServerAlias *.exampleA.com
  
          RewriteEngine On
          Redirect 301 / https://exampleB.com
  &lt;/VirtualHost&gt;
  </code></pre>