"Bernd Liebermann" <12**@bernd-liebermann.de> wrote in message news:<c1**********@online.de>...
Hi,
I have a problem with redirection using the header function. The page
towards which I redirect loads correctly, but the url in the browser's
address bar is different is that of the redirecting page. Both pages are
located in different directories, so that my relative links don't work in
the page, because the browser retrieves the current directory from the wrong
url in the location bar.
This problem occurs only on the server of my webhosting provider, not on my
local machine where I can see the correct url after redirection. So I
assume, this is a server specific setting. But how can I change ist?
/**----------------------------------------------------------------------------------
* Redirect2URL()-Redirects to the given URL
*
* @param $url - can be absolute/relative url eg.
http://foo.com/foo.htm or just foo.htm
* @return - void
**/
function Redirect2URL($url)
{
$url = trim($url);
//note: === (three equal signs)...otherwise it won't work
if ( ! preg_match("/^http:\/\/|https:\/\/|ftp:\/\//i", $url) ) //if
http:// is not found, then the url is relative...
$url = 'http://' . $_SERVER['HTTP_HOST'] .
(strpos($url, '/') === 0? $url :
(dirname($_SERVER['PHP_SELF']).'/'.$url));
header('Location: ' . $url); //use absolute URI
exit; // Make sure that code below does not get executed when we
redirect.
}/*---------Redirect2URL()-----------------------*/
This may work.
--
"Success is not what you achieve, but it is what you die for"
If you live in USA, please support John Edwards.
Email: rrjanbiah-at-Y!com