• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

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


0
rcinformatica
Asked:
rcinformatica
  • 4
  • 3
  • 3
1 Solution
 
RoonaanCommented:
You have to swap the echo and the header line.

-r-
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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\">";
?>

0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
full sample:

<HTML><HEAD>
<?
$domain = $_SERVER['HTTP_REFERER'] ;
$dest = "http://www.ndparking.com/";
echo "<META HTTP-EQUIV=\"Refresh\"
      CONTENT=\"5; URL=$destinazione$domain\">";
?>
</HEAD>
<BODY>
  Redirecting, please wait (5 seconds)...
  or click <a href="<?php echo "$destinazione$domain" ?>">here</a>
</BODY>
</HTML>
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
rcinformaticaAuthor Commented:
thanks,

it redirects but to http://www.ndparking.com/ instead fo http://www.ndparking.com/$domain
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
then, $_SERVER['HTTP_REFERER'] returns nothing, possibly the server setting is not enabled to fill in that value?
0
 
rcinformaticaAuthor Commented:
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
0
 
RoonaanCommented:
Addtionaly, some browsers are configured not to send a http_referer header at all (as is mine).

-r-
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
'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.
0
 
rcinformaticaAuthor Commented:
Hi I changed HTTP_REFERER  with HTTP__HOST and it works now thanks
0
 
RoonaanCommented:
HTTP_HOST always refers to the server the script is running from. Hence always being: ndparking.com.

-r-
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

  • 4
  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now