Here is a quick SEO question. We decided to split our web site into two different sites. Google has already crawled 50K pages which we want to move to another domain name. My question is what would be the best way to deal with it as we want only certain URLs to be redirected not the whole website. Should I do mode rewire catch the get parameters and send them over to the new domain name? or should I do it with php headers?
olddomain.com becomes oldomain.com and newdomain.com
oldomain.com?name=jw&gsurname=black –> newdomain.com?name=jw&gsurname=black
oldomain.com with any other url structure should stay the same
2
Answers
You should be able to use the
RewriteCond
andRewriteRule
directives together to match against query string values, like so:If you mean exactly that set of query parameters:
The RewriteCond looks at the query string and checks that the first parameter is name and the second parameter is gsurname. The
([^&]+)
collects all of the characters until it finds an ampersand (^& means not ampersand). The(.*)$
collects characters until the end of the query string ($).If the RewriteCond is true, then the RewriteRule redirects to the new domain. The query string is automatically passed along as-is.