Link to home
Start Free TrialLog in
Avatar of rcinformatica
rcinformatica

asked on

Php Redirect

Hi Experts,

I need to create a PHP page that redirects to namedrive.com, the destination URL should be:

http://www.ndparking.com/nameofdomain.com

this is the script:

<?
$domain = $_SERVER['HTTP_REFERER'] ;
$dest = "http://www.ndparking.com/";
echo "redirecting please wait";
header("location: $destinazione$domain");
exit;
?>


but I cannot get it to work,

could you help me please


Avatar of Roonaan
Roonaan
Flag of Netherlands image

You have to swap the echo and the header line.

-r-
or, if you really want the "redirecting" to be shown, use the META tag:

<?
$domain = $_SERVER['HTTP_REFERER'] ;
$dest = "http://www.ndparking.com/";
echo "<META HTTP-EQUIV=\"Refresh\"
      CONTENT=\"5; URL=$destinazione$domain\">";
?>

ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rcinformatica
rcinformatica

ASKER

thanks,

it redirects but to http://www.ndparking.com/ instead fo http://www.ndparking.com/$domain
then, $_SERVER['HTTP_REFERER'] returns nothing, possibly the server setting is not enabled to fill in that value?
thanks I believe you are right, what I need to do is :

I type the URL in the browser http://www.name.com

the script redirects to http://www.ndparking.com/name.com

could you help me getting this script

thanks
Addtionaly, some browsers are configured not to send a http_referer header at all (as is mine).

-r-
'HTTP_REFERER'

The address of the page (if any) which referred the user agent to the
current page. This is set by the user agent. Not all user agents will set
this, and some provide the ability to modify HTTP_REFERER as a feature. In
short, it cannot really be trusted.

Don't forget that people can start with a blank page on the browser and jump
to your page, in that case you too get a blank data.
Hi I changed HTTP_REFERER  with HTTP__HOST and it works now thanks
HTTP_HOST always refers to the server the script is running from. Hence always being: ndparking.com.

-r-