PDA

View Full Version : Dynamic Redirection In Php?


tstern
06-20-2004, 07:54 AM
Hi everyone. I'm looking to create a PHP script, but since I don't really know the language well, I figured I'd drop a note in here to see if dbmasters or eugene or any of our other resident PHP gurus had any ideas.

I'll just reproduce my blog post asking if anyone had ideas.

(NOTE: I'm not looking for anyone to dig deeply into this problem, I just figured the answer might begin with, "Actually, it's pretty simple...")

Thanks in advance!

* * ** * * "*"**"*""*""*

The permalinks to blog entries on my site are of the format, http://www.sugarmrpoon.com/weblog.php?id=PXXXX, with the "XXXX" being the post ID number (currently from 1 to 2870). This post is number 2870, so the permalink is http://www.sugarmrpoon.com/weblog.php?id=P2870

Anyway, what I'm looking to do is have the permalinks in my old domain, blog.tstern.com, forwarded automatically to the permalinks in sugarmrpoon.com.

I.e., if someone goes to blog.tstern.com/weblog.php?id=P1234, they'll be automatically re-directed to sugarmrpoon.com/weblog.php?id=P1234.

That is, I need a dynamic redirection. (Currently, anything hitting blog.tstern.com/weblog.php simply forwards you to sugarmrpoon.com, without preserving the permalink information.)

If you have a clue as to how to achieve this feat, or know someone who might, please let me know.

Thanks.

thevillageinn
06-20-2004, 06:32 PM
I'm going to answer this the same as I did just a second ago to a different question.

can't this be done in .htaccess with the "Redirect" directive?

However, maybe that solution is dependent on whether blog.tstern.com and sugarmrpoon.com reside on the same account and thus in the same user's directory tree?

tstern
06-21-2004, 10:01 AM
one of my readers gave me the following code, which worked:

<?php
$id=$_GET['id']; header("Location:http://www.sugarmrpoon.com/weblog.php?id=$id");
?>