phpretard Posted March 20, 2009 Share Posted March 20, 2009 I am trying to simulate a default 404 for all sites on my server. I need to parse the referring page and redirect to the home page of the applicable site. Here's what I have so far... <?php $url=$_SERVER['HTTP_REFERER']; //$url = 'https://www.dontmatter.com/index.php?limitstart=3 '; // this was for testing print_r(parse_url($url)); echo parse_url($url, PHP_URL_PATH); $404F=$???; // I am trying to get the [host] value from this array and put it in a var. header( "Location: $404F" ) ; ?> Thank you PS. this is just a band aid until I figure out Plesk Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 20, 2009 Author Share Posted March 20, 2009 How can I Get "www.dontmatter.com" out of the array and into a variable. Array ( [scheme] => https [host] => www.dontmatter.com [path] => /index.php [query] => limitstart=3 ) /index.php Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 20, 2009 Author Share Posted March 20, 2009 Is this a tough question? I thought it would be easy (for someone)... Quote Link to comment Share on other sites More sharing options...
phant0m Posted March 20, 2009 Share Posted March 20, 2009 yes, it is easy <?php $host = parse_url($url); $host = $host['host']; header("Location: $host"); ?> I suggest you to do some reading about arrays Quote Link to comment Share on other sites More sharing options...
redarrow Posted March 20, 2009 Share Posted March 20, 2009 <?php $url=array("scheme"=>array("host"=>"www.dontmatter.com") ,"path"=>array("/index.php"),"query"=>array("limitstart=3")); $the_url=$url['scheme']['host']; echo $the_url; ?> Quote Link to comment Share on other sites More sharing options...
phant0m Posted March 20, 2009 Share Posted March 20, 2009 <?php $url=array("scheme"=>array("host"=>"www.dontmatter.com") ,"path"=>array("/index.php"),"query"=>array("limitstart=3")); ?> This is not, what parse_url returns. It returns a (one-dimensional) associative. "scheme" is the key, which contains the protocol(eg.g http, https), it is not an array Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.