Pablo: URI auslesen

Beitrag lesen

Ahoi,

ich habe mal gelesen, dass man für eine Weiterleitung per header-location immer einen vollständigen URI braucht.

Bei HTTP/1.1 trifft das zu.

Meine Frage: gibt es in PHP eine Möglichkeit den URI der aktuellen Seite auszulesen? Wenn ja, wie? Ich habe einfach nichts gefunden :-(

Auf der Doku von php.net gibt es ein eigenes Beispiel dazu:

Note:  HTTP/1.1 requires an absolute URI as argument to Location:  including the scheme, hostname and absolute path, but some clients accept relative URIs. You can usually use $_SERVER['HTTP_HOST'], $_SERVER['PHP_SELF']  and dirname() to make an absolute URI from a relative one yourself:

<?php  
/* Redirect to a different page in the current directory that was requested */  
$host  = $_SERVER['HTTP_HOST'];  
$uri  = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');  
$extra = 'mypage.php';  
header("Location: http://$host$uri/$extra");  
exit;  
?>

Gruß,
Pablo

--
ie:% fl:| br:^ va:) ls:[ fo:) rl:? n4:( ss:) de:> js:| ch:? sh:( mo:) zu:)
Aarakast.de