Jump to content

[SOLVED] Parse URL and Redirect


phpretard

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/150296-solved-parse-url-and-redirect/
Share on other sites

<?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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.