1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Looking for specific type of re-direction script

Discussion in 'General Scripting Chat' started by Inflow, Feb 2, 2010.

  1. Inflow

    Inflow Newbie

    Joined:
    Dec 20, 2009
    Messages:
    26
    Likes Received:
    42
    Hi, most scripts that I've found seem to be ones which re-direct users from X site to X site.. but I'm looking for a different type of script. I'm looking for one that will take note of where the user is coming from so something like (and im not a scripter here)


    If incomingurl ='http://www.website.com/page1'
    then go to http://www.website.com/page1

    I know you might think its a bit silly because you could just setup directories on the server which contains the adderess but in my case
    it's a .co.cc site which re-directs so the files arent hosted on .co.cc host.


    If anyone knows where I can find the above script I would be very appreciative. Thank you
     
  2. n2zen

    n2zen Regular Member

    Joined:
    Sep 27, 2009
    Messages:
    269
    Likes Received:
    70
    You mean something like the following? It will check referring URL and if it matches what you are looking for, they'll get auto directed to the header... line.
    PHP:
    <?php
    $ref 
    getenv("HTTP_REFERER");
    if (
    $ref 'http://www.exacturlgoeshere.com') {
    header('Location: http://www.website.com/page1/');
    }
    ?>
     
    • Thanks Thanks x 1
  3. yeahright

    yeahright Registered Member

    Joined:
    Jan 17, 2009
    Messages:
    93
    Likes Received:
    32
    The code posted is incorrect and will not work correctly. Double equal signs (==) are needed instead of single.

    This (imo) would be the most elegant solution:

    PHP:
    <?php

    if($_SERVER['HTTP_REFERER'] == 'http://www.website.com/page1.html') {
    header('Location: http://www.whatever.com'); 


    ?>

    And yes for direct traffic remove the http://www.website.com/page1.html.