PHP Redirects: Am I losing traffic?

Discussion in 'HTML & Website Design' started by mbelmont, Sep 17, 2010.

  1. #1
    Hi all,

    Right now everyone who visits the Index page of my website is being redirected to another page using a simple PHP redirect script.

    Do some people have browsers or security settings that don't allow redirection? Or is there a way I can get around this?

    I just don't want to lose traffic if people are getting security warnings about redirection, etc.

    Here's a sample of the code I'm using:

    <?php
        $redirects = array(
    
    "affiliate" => "http://www.howtobehandsome.com/affiliates/",        
            
    "" => "http://www.howtobehandsome.com/index7.php"
        
    );
    
        $itm = $_GET["itm"];
    
        if (array_key_exists($itm, $redirects)) {
            $go = $redirects[$itm];
            header("Location:$go");
            die();
        }
    ?>
    Code (markup):
    Thanks in advance! :cool:
     
    mbelmont, Sep 17, 2010 IP
  2. mcfox

    mcfox Wind Maker

    Messages:
    7,526
    Likes Received:
    716
    Best Answers:
    0
    Trophy Points:
    360
    #2
    If you use .htaccess and a redirect you won't need the php script at all.
     
    mcfox, Sep 17, 2010 IP
  3. mbelmont

    mbelmont Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Hi mcfox, thanks for the reply.

    The reason I'm using the redirect script is so that I can divert traffic depending on its source. If "Bob" refers a visitor to my site, for example, his link to my site will include the custom value "?itm=bob" after my URL...

    The PHP script then sees "bob" and diverts the visitor to a landing page titled "bob.html" which is customized with content relevant to Bob's traffic.

    In other words, the goal is to redirect traffic to different pages depending on where they're coming from.

    Is there a way to do this using .htaccess? I'm familiar with a simple .htaccess redirect, but I don't know of a way to pass custom values and specify redirects based on those values...

    Thanks!
     
    mbelmont, Sep 17, 2010 IP
  4. mrdeflation

    mrdeflation Member

    Messages:
    368
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    28
    #4
    is the page you are redirecting from indexed or ranked in google?
     
    mrdeflation, Sep 18, 2010 IP
  5. mbelmont

    mbelmont Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, but it's got low PR. My traffic (and my sales in general) are mostly referred by affiliates, so I've never put much effort into SEO.

    Does Google frown upon the redirects?
     
    mbelmont, Sep 18, 2010 IP
  6. dreamconception

    dreamconception Peon

    Messages:
    55
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    .htaccess can be used on the query as well, however you do need good knowledge into rewrite rules.

    Most browsers accepts redirects, I haven't experienced any problems yet with PHP header redirect.
     
    dreamconception, Sep 18, 2010 IP
  7. mbelmont

    mbelmont Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Good to know, thanks. Unless there's a compelling reason to switch to an .htaccess redirect, I'll stick with the PHP script. (Posted this thread just because I want to be sure I'm not losing a meaningful portion of my traffic because of the redirect.)
     
    mbelmont, Sep 18, 2010 IP
  8. Martenxxx

    Martenxxx Peon

    Messages:
    27
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    You have to allways send 301 code in header, that you will not lose any traffic or pagerank.
     
    Martenxxx, Sep 24, 2010 IP