runnerjp Posted July 17, 2009 Share Posted July 17, 2009 how comes my redirect echos out index.php?page=message&forum=$forum&id=$forumpostid&pagenum=last and not the php output... well i cant think of the word lol but the output of $forum is what i mean lol minds gone blank header('Location: index.php?page=message&forum=$forum&id=$forumpostid&pagenum=last'); Link to comment https://forums.phpfreaks.com/topic/166348-php-within-a-header-redirect/ Share on other sites More sharing options...
ldougherty Posted July 17, 2009 Share Posted July 17, 2009 The loaction header must contain an absolute URI!! See note above "Note: HTTP/1.1 requires an absolute URI as argument to » Location". Thus: <?php header("Location: /home.php"); ?> is wrong, but most browsers will follow it correctly (hence the common mistake). This is correct: <?php header("Status: 301"); # 301 Moved Permanently header("Location: http://{$_SERVER['SERVER_NAME']}/home.php"); exit; ?> Link to comment https://forums.phpfreaks.com/topic/166348-php-within-a-header-redirect/#findComment-877315 Share on other sites More sharing options...
phporcaffeine Posted July 17, 2009 Share Posted July 17, 2009 You are trying to iterate variable values inside single quotes. Either use double quotes or concatenate it. header('Location: http://mydomain.com/index.php?page=message&forum=$forum&id=$forumpostid&pagenum=last'); SHOULD/COULD BE header('Location: http://mydomain.com/index.php?page=message&forum=' . $forum . '&id=' . $forumpostid . '&pagenum=last'); OR header("Location: http://mydomain.com/index.php?page=message&forum=$forum&id=$forumpostid&pagenum=last"); Link to comment https://forums.phpfreaks.com/topic/166348-php-within-a-header-redirect/#findComment-877356 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.