Page 1 of 1

Redirect, but keep uri the same

Posted: Tue Feb 20, 2007 7:06 pm
by Luke
Is there any way WITHIN PHP or with headers to redirect somebody to a new location, but keep the URI the same (in the URL)?

Posted: Tue Feb 20, 2007 7:20 pm
by WaldoMonster

Code: Select all

<?php
header('Location: http://www.newlocation.com' . $_SERVER['REQUEST_URI']);
?>

Posted: Tue Feb 20, 2007 7:33 pm
by Luke
wouldn't that just redirect me to the same page I'm on? I need to redirect to a new location.

Posted: Tue Feb 20, 2007 7:46 pm
by WaldoMonster
The Ninja Space Goat wrote:wouldn't that just redirect me to the same page I'm on? I need to redirect to a new location.
if run form: http://www.oldsite.com/something/index.php
it will redirect to: http://www.newlocation.com/something/index.php

If this is not what you want, please give an example.

Posted: Tue Feb 20, 2007 10:54 pm
by Kieran Huggins
You want to cloak the URL? You could include() the URL you're redirecting to, but that seems sloppy to me.

Why not mod_rewrite?

Posted: Wed Feb 21, 2007 1:20 am
by dude81
write a function on mod-rewrite of apache using php