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

Redirect wold Wordpress tags?

Discussion in 'White Hat SEO' started by googleme7, Aug 13, 2011.

  1. googleme7

    googleme7 Newbie

    Joined:
    Jan 13, 2010
    Messages:
    35
    Likes Received:
    3
    Occupation:
    Internet Marketing
    Location:
    USA
    Home Page:
    Hello,

    Is it possible to redirect old Wordpress tags to my homepage? I had a blog setup before In my main directory. I replaced it with HTML website and now Google is crawling the old domain.com/?tag-name and showing duplicate content in the SERPS. Please help!

    Thank You
     
  2. Autumn

    Autumn Elite Member

    Joined:
    Nov 18, 2010
    Messages:
    2,197
    Likes Received:
    3,041
    Occupation:
    I figure out ways to make money online and then au
    Location:
    Spamville
    I assume your default file in your root directory is index.html. Basically if a query comes in with a known query string, you want to redirect it.

    Add this at the very top of your index.html file:

    Code:
    <?php
    
    $tags = array(
    	'tag-1',
    	'tag-2'
    );
    
    $main_url = 'http://www.rootdomain.com/';
    
    if($_GET) {
    	foreach($_GET as $key => $value) {
    		if(in_array($key, $tags)) {
    			header("Location: $main_url", true, 301);
    		}
    	}
    }
    
    ?>
    
    Fill in the list of tags you want to redirect (with hyphens in them, as they appear in the url) and the url you want to redirect them to. Now if a request comes in with those tags appended to the index.html file, they'll be redirected to your desired url with a 301.

    You may need to enable the parsing of php on domain.com/index.html via .htaccess, just google "parse html for php htaccess" for tutorials.
     
    Last edited: Aug 13, 2011