Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm hoping one of you WP gurus can help me out here...

I have a website. Let's call it Jack.com

I'm re-branding Jack as a girl, so I've made another website website - Jill.com

I want all existing links that are spread out over the net to be redirected to the equivalent, sister page eg. Jack.com/article_12 needs to redirect to Jill.com/article12

Also, If the user types in or clicks on "Jack.com/article_12" but they arrive at Jill.com it's going to leave them a bit confused. So I'd like to intercept the forwarding with a nice visual page that says "Thanks for visiting, Jack is now a girl called Jill, you are being forwarded to Jill.com/article12" and then redirect the user onto their destination after 5 seconds or so on that intermediate page.

I'm an experienced developer, but WordPress is a total alien to me and I've never had to do this kind of thing before... Can one of you clever people out there explain how I'd go about doing that ?

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

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.

share|improve this answer
    
Hi Sunyatasattva, Thanks for your post, it sounds encouraging ! I should have pointed out that I'm an experienced developer in vb.net & c# but not php at all. Are you saying that I need to create a new .php file (and include the header tags you suggest above) and place it in the root of Jack.com? With .htaccess - would I use this line ? RewriteRule ^(.*)$ http://www.jill.com/ [R=301] That may be wrong because you also said : You would have to fetch the particular name of the article which brought the user there, and you can do that with simple PHP What would that php look like ? –  wotney Feb 14 '13 at 10:58
    
(Removing the underscore from the URL in the example was an accident, the article titles will stay the same) –  wotney Feb 14 '13 at 10:59
    
I have written a few solutions from you, check them out. –  Sunyatasattva Feb 14 '13 at 12:36
    
Sunyatasattva - I'm very sorry about my sporadic replies - I WILL be trying your solutions as soon as my boss gives me some time ! In the meantime - please know that I very much appreciate your help here :) –  wotney Feb 15 '13 at 10:55
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.