Support » Fixing WordPress » Redirecting post from blogger

  • Hi, I used to use a account for my blogger, but I just installed a WP blog and its great! But since I used blogger for a long time, I already got many posts indexed in google. So, I would like to redirect all the users from google to my new posts. OK, I already created a “from_blogger.php” file, and it worked great in my test WP install, but when I transfer the DNS, the user will see the 404 eror page, not the from_blogger.php page I made.

    Anyway, I tought about this solution: Add the from_blogger.php code in the 404 WP page.
    the from_blogger page works in the following way:

    So, here are my questions:
    1. When the user visit the 404 page, how do I get the URL that brought it to the 404 page?

    2. Where should I place the code in the 404 page?

    3. which is the 404 page from WordPress? 😛

    here is the code from the “from_blogger.php” page:

    $search_link = $_GET['p'];
    $vars = explode('/', $search_link);
    $num = count($vars) - 1;
    $filename = $vars[$num];
    $slug = str_replace(".html", "", $filename);
    $SQL = "SELECT * FROM wp_posts WHERE post_name LIKE '$slug%' LIMIT 1";
    $posts = $wpdb->get_results($SQL);
    if ($posts) {
    	foreach ($posts as $post) {
    		$found_link = get_permalink($post->ID);
    		$found_link = "";
    Header( "HTTP/1.1 301 Moved Permanently" );
    Header( "Location: $found_link" ); 

    btw, im willing to change the “ELSE” part with the original 404 error code.


  • The topic ‘Redirecting post from blogger’ is closed to new replies.