Page 1 of 1

redirection

Posted: Mon Mar 10, 2003 9:58 am
by gecko
i have two url's (url_x and url_y) both going to one and the same website (website_x). basically url_y is redirected to website_x.

When typing in url_y in the browser I would still like to go to website_x, but i would also like a popup window to appear, that I do not want to pop-up when someone types in url_x, while both url's still point to the same website.

Is this at all possible

thanks

Posted: Mon Mar 10, 2003 11:28 am
by daven
Couple of ways:

Javascript:
Put this on the index page of url Y (the one you want the message to appear on)

Code: Select all

<script language="javascript">
alert("You are at URL Y");
self.location="www.websiteX.org";
</script>
PHP:
Put this on the index page of websiteX (where everything eventually goes to)

Code: Select all

<?php
if($_SERVER['HTTP_REFERER']=="urlY"){
  <script language="javascript">
  alert("You came from URL Y");
  self.location="www.websiteX.org";
  </script>
}
?>
NOTE: $_SERVER['HTTP_REFERER'] is not completely reliable. Check out the PHP Manual (Predefined Variables) for documentation