skip to Main Content

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


  1. You should be able to use the RewriteCond and RewriteRule directives together to match against query string values, like so:

    RewriteEngine On
    RewriteCond %{QUERY_STRING} ^name=([^&]+)&gsurname=([^&]+)$
    RewriteRule ^(.*)$ http://newdomain.com?name=%1&gsurname=%2 [R=301,L]
    
    Login or Signup to reply.
  2. If you mean exactly that set of query parameters:

    RewriteCond %{QUERY_STRING} ^name=([^&]+)&gsurname=(.*)$
    RewriteRule ^/$ http://newdomain.dom [R=301, L]
    

    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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search