How can I create VirtualHost to redirect all links changing only its domain, including subdomain and parameters:
exampleA.com -> exampleB.com
test.exampleA.com -> test.exampleB.com
test1234.exampleA.com/url/test.html?param=222 -> test1234.exampleB.com/url/test.html?param=222
I want to redirect all subdomains like *, and it should be permanent 301
Now I have a simple 301 redirection
<VirtualHost *:80 *:443>
ServerName exampleA.com
ServerAlias *.exampleA.com
RewriteEngine On
Redirect 301 / https://exampleB.com
</VirtualHost>
2
Answers
I found the solution:
I have never done something like this, but try the redirect option in your virtualhost file. First enable rewrite
Then in your virtualhost file
Read more about this here: https://httpd.apache.org/docs/2.4/rewrite/remapping.html
It takes the original domain and rewrites to another. In older apache I remember it goes something like this: