PDA

View Full Version : Changing host, need to forward users with php code


mOdEtWo
06-07-2004, 12:48 PM
Ok, this is the case:

Since we've been using too much bandwidth on our dedicated server lately, we have to move the forums to another host with cheaper bandwidth. I've already bought and configured this, and I set up a new domain for the forums.

So, what I need to do when changing host, is to redirect users to the new host. I was going to use a .htaccess file with the Redirect setting, but Apache on that server doesn't allow such settings in .htaccess files. So, I need to figure out something else.

We have just released a new piece of software (game actually), and we're getting linked to from everywhere (even slashdot ). So I can't just delete the vB forums off the dedicated server and breake the links. I *need* to sort something out here.

Floris answeared me on the official forums, and told me to try:
<?php
header("Location: http://www.yournewsite.com/forum/");
?>

I then figured I could replace all other code with this code in the common php files that get linked to from other places, like showthread.php, index.php etc.

So now, when a user visits myolddomain.com/forums, they get forwarded to mynewdomain.com/forums. So far so good. But when they are linked to a spesific thread, like myolddomain.com/forums/showthread?t=3813, they are still just forwarded to mynewdomain.com/forums, and not to the spesific thread.

I told Floris this, and he told me to try:
if ($_REQUEST)
{
header("Location: http://www.yournewsite.com/forum/");
}
if (empty($_REQUEST))
{
header("Location: http://www.yournewsite.com/forum/");
}
And then he said:
As you can see in the code, it doesn't include any thread id catching, etc.
If the above code works, catch the id and set it to a variable, then add the variable to the end of the header.location url.

Now, how do I do that!? I want myolddomain.com/forums/showthread?t=3813 to be forwarded to mynewdomain.com/forums/showthread?t=3813

mOdEtWo
06-07-2004, 05:22 PM
Too much text to read for ya, eh?

;)