Redirecting old site links to new site

I don’t think this needs any WordPress at all. I would set up a single .php script setting the headers as such:

    header("HTTP/1.1 301 Moved Permanently"); 
    header('Refresh: 5; URL=http://jill.com/name_of_the_article');

And then whatever content you wish. Then I would set up a redirect to the said .php script. You would have to fetch the particular name of the article which brought the user there, and you can do that with simple PHP or using WordPress functions if you so wish (depending how complicated is your redirection, you probably don’t need that at all). Also, if you use a different slug standard in your new site (as you seem to suggest by removing the underscore), as long as the change is pretty simple, this is going to be quite easy.

If you have problems doing that, we can look into this problem.

EDIT

SOLUTION 1: The simple solution
This is the simplest solution, using .htaccess, but you don’t get any timer. Create an .htaccess file in the root of your former domain with the following rules:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^www.jack.com
RewriteRule (.*) http://www.jill.com/$1 [R=301,L]

SOLUTION 2: The more convoluted solution
Make a php script like so:

<?php
    $article = $_GET['article']
    header("HTTP/1.1 301 Moved Permanently"); 
    header("Refresh: 5; URL=http://jill.com/$article");
?>

<!-- Your HTML goes here, display the timer and whatever you wish -->

Then add the following code to your functions.php files in WordPress current theme (or use it as a plugin).

function redirect_to_new_site() {

    $article = basename( get_permalink() );
    wp_redirect( "http://jack.com/link-to-your-php-script.php?article=$article", 301);

};

    add_action('wp_head', 'redirect_to_new_site');

I have tested this solution and it works.

Leave a Comment