redirection

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
gecko
Forum Commoner
Posts: 34
Joined: Thu Oct 24, 2002 3:45 am

redirection

Post 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
User avatar
daven
Forum Contributor
Posts: 332
Joined: Tue Dec 17, 2002 1:29 pm
Location: Gaithersburg, MD
Contact:

Post 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
Post Reply