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

Keyword based redirect?

Discussion in 'PHP & Perl' started by Kingfresh, Jun 23, 2010.

  1. Kingfresh

    Kingfresh Regular Member

    Joined:
    Jul 8, 2009
    Messages:
    374
    Likes Received:
    295
    Hey guys, how i can build a script or what code i have to include into a script to build a keyword based redirect?


    I dont want to link p1-->p2 etc.

    I want to link p1-->redirect script -->p2,p3,p4


    So if i click money , it loads the script and redirect me to money.html etc. instead of direct linkin ... is there anything out there?

    thanks!
     
  2. voyevoda

    voyevoda Regular Member Premium Member

    Joined:
    Mar 21, 2010
    Messages:
    217
    Likes Received:
    97
    Location:
    Eastern Front
    You mean something like this?

    redirect.php

    PHP:
    <?php

        
    switch($_GET['keyword'])
        {
            case 
    'cars':
                
    $uri '/cars.html';
            break;

            case 
    'stacks':
                
    $uri '/stacks.html';
            break;

            
    // Multiple matches for a single destination page
            
    case 'money':
            case 
    'cash':
            case 
    'hoes':
                
    $uri '/jay-z.html';
            break;

            default:
                
    $uri '/'// Redirect to homepage if no match...
            
    break;
        }
        
        
    header("Location: $uri");

    ?>

    And you would link to it like this:

    Code:
    http://yoursite.com/redirect.php?keyword=money
     
    • Thanks Thanks x 1
  3. Kingfresh

    Kingfresh Regular Member

    Joined:
    Jul 8, 2009
    Messages:
    374
    Likes Received:
    295
    hey buddy thanks!

    and is there anyway to combine it with a redirect script?

    here is mine:
    PHP:
    <?php
    require_once("geoip.inc");

    $gi geoip_open("GeoIP.dat",GEOIP_STANDARD);

    $country_code geoip_country_code_by_addr($gi$_SERVER['REMOTE_ADDR']);
    geoip_close($gi);

    if(
    $country_code == 'US')
    {
            
    header('Location: /fbappguide.com/offer/us/');
    }
    elseif(
    $country_code == 'DE')
    {
            
    header('Location: http://fbappguide.com/offer/de/');
    }
    elseif(
    $country_code == 'GB')
    {
            
    header('Location: http://GBTraffic.com');
    }
    elseif(
    $country_code == 'CA')
    {
            
    header('Location: http://CATraffic.com');
    }

    else {
            
    header('Location: http://AllTraffic.com');
    }
    ?>
     
  4. voyevoda

    voyevoda Regular Member Premium Member

    Joined:
    Mar 21, 2010
    Messages:
    217
    Likes Received:
    97
    Location:
    Eastern Front
    PHP:
    <?php 

        
    require_once('geoip.inc');

        
    $gi geoip_open('GeoIP.dat',GEOIP_STANDARD);
        
    $country_code geoip_country_code_by_addr($gi$_SERVER['REMOTE_ADDR']);
        
    geoip_close($gi);

        switch(
    $country_code)
        {
            case 
    'US':
                
    $uri '/fbappguide.com/offer/us/';
            break;

            case 
    'DE':
                
    $uri 'http://fbappguide.com/offer/de/';
            break;

            case 
    'GB':
                
    $uri 'http://GBTraffic.com';
            break;

            case 
    'CA':
                
    $uri 'http://CATraffic.com';
            break;

            default:
                
    $uri 'http://AllTraffic.com';
            break;
        }

        
    header("Location: $uri");

    ?>
     
  5. akwin4565

    akwin4565 Junior Member

    Joined:
    Dec 1, 2013
    Messages:
    135
    Likes Received:
    7
    Location:
    in front of bhw
    without the redirect.php i need to redirect directly like the below example:

    Code:
    http://yoursite.com/?money
    as it mentioned as money it should redirect to the specified page