1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

301 Redirect Issue With Query String

Discussion in 'Black Hat SEO' started by 730promo, Nov 29, 2012.

  1. 730promo

    730promo Junior Member

    Joined:
    Aug 27, 2009
    Messages:
    130
    Likes Received:
    12
    Occupation:
    Music Management and Marketing
    Location:
    Reading
    Home Page:
    Hi guys,
    I was hoping someone could give me some advice with 301 redirect. I have recently moved domains and got a redirect on my domain from the old one to the new one. This works for all of the files except ones with have a query string in the URL.
    e..g
    www.olddomain.com/example.php - redirect to index of new site
    www.olddomain.com/example/ - redirect to index of new site
    www.olddomain.com/example?id=2 - redirects to the new site but to the 404 page.

    My current 301 redirect reads.
    #RewriteRule ^(.*)$ "http\:\/\/www\.olddomain\.com\/$1" [R=301,L]
    RewriteRule ^(.*)$ "http\:\/\/www\.newsite\.com\/" [R=301,L]

    Can anyone advise me of what code to put into the htaccess file so i can redirect ALL urls WITH a query string to the index page of the new site

    Thanks in advance
     
    Last edited: Nov 29, 2012
  2. proweb

    proweb Regular Member

    Joined:
    Feb 24, 2011
    Messages:
    291
    Likes Received:
    144
    So you want to redirect ALL URLs to the index page?

    Use this in .htaccess:
    redirect 301 / http://YourIndexPageUrl
     
  3. alexglo

    alexglo Junior Member

    Joined:
    Aug 12, 2011
    Messages:
    166
    Likes Received:
    145
    Location:
    UK
    Hi you would do something like this:

    RewriteCond %{QUERY_STRING} ^id=2$ [NC]
    RewriteRule ^www\.olddomain\.com/example$ /www.newdomain.com/newpath [R=301]

    Edit:
    Totally misread the question! But if you want to redirect exact query strings to exact pages you'd do something like this.
     
  4. 730promo

    730promo Junior Member

    Joined:
    Aug 27, 2009
    Messages:
    130
    Likes Received:
    12
    Occupation:
    Music Management and Marketing
    Location:
    Reading
    Home Page:
    hi guys yeh just to clarify im looking to redirect all urls that have a query string to the main page. 90% of all the pages on the site are redirected to the index page with the exception of a few.

    So i take it as going to a query string on the old site takes me to a 404 on the new one the query string is passed over in the redirect. so www.oldsite.com/example?=2 would take you to www.newdomain.com?=2 and thats where the 404 is coming from?