I have a old domain with a old url structure and want redirect (301) it to an another domain with a new url-structure. I have urls that must be transform individually:
http://domainA.com/ => http://ru.domainB.com/ http://domainA.com/?fieldA=abc => http://ru.domainB.com/xxx/zzz http://domainA.com/?fieldA=www&fieldB=aaa => http://ru.domainB.com/uuu/ooo/ppp
another urls have the same values:
http://domainA.com/?fieldC=abc&fieldD=4 => http://ru.domainB.com/abc/xxx/4 http://domainA.com/?fieldC=abc&fieldD=5 => http://ru.domainB.com/abc/xxx/5 http://domainA.com/?fieldC=abc&fieldD=6 => http://ru.domainB.com/abc/xxx/6 http://domainA.com/?fieldC=def&fieldD=4 => http://ru.domainB.com/def/xxx/4 http://domainA.com/?fieldC=def&fieldD=5 => http://ru.domainB.com/def/xxx/5 http://domainA.com/?fieldC=def&fieldD=6 => http://ru.domainB.com/def/xxx/6
left side urls can have optional "index.php" before "?" or "www." before domain name. Can anybody help me here and translate this 4 links with mod_rewrite(apache), please?
My account have multiple domain-names for one webspace (wildcard subdomains). Pseudo setting in apache conf:
ServerAlias *.domainA.com ServerAlias *.domainB.com ServerAlias *.domainC.com ServerAlias *.domainD.com
EDIT: This helps me.
RewriteCond %{HTTP_HOST} ^(www\.|)domainA\.com RewriteCond %{QUERY_STRING} fieldA=xxx) RewriteRule ^(.*)$ http://ru.domainB.com/? [R=301,L] RewriteCond %{HTTP_HOST} ^(www\.|)domainA\.com RewriteCond %{QUERY_STRING} fieldA=abc RewriteRule ^(.*)$ http://ru.domainB.com/abc/bbb/? [R=301,L] RewriteCond %{HTTP_HOST} ^(www\.|)domainA\.com RewriteCond %{QUERY_STRING} fieldA=abc&fieldB=(\d+) RewriteRule ^(.*)$ http://ru.domainB.com/abc/%1? [R=301,L]