1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

URL Redirection Option. Which is better?

Discussion in 'PHP' started by Bohol, Mar 13, 2008.

  1. #1
    I post this topic here assuming there must be some experts in php and html coding.

    I can set up redirection both using .php file and .html file. My concern is speed and browser compatibility (Firefox, IE), plus Norton's attempt to block a redirected url.

    So what should I do? Choose .php in redirecting a url or choose an .html redirection?
     
    Bohol, Mar 13, 2008 IP
  2. DopeDomains

    DopeDomains Guest

    Messages:
    207
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    My preferred way, if you don't need a 'tween' page is

    php:
    
     header('Location: http://dest.com/');
    
    PHP:
    It's what I use for my tinyurl clone i40.com

    -Jason
     
    DopeDomains, Mar 13, 2008 IP
  3. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #3
    hi DopeDomains,

    I am using this but it seems a bit slow:

    <?php
    header("location:http://www.exampledomain.com/go/to.php");
    exit;
    ?>

    Is that code correct?
    And I save in whatevername.php and upload it in the server. But it seems slow. What do you think?
     
    Bohol, Mar 13, 2008 IP
  4. DopeDomains

    DopeDomains Guest

    Messages:
    207
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Is that at the top of your .php file before any other processing?

    Check the speed of:
    http://i40.com/BER6Csn
    (It links right back to this thread via the above code). If it is slower than that, you are having a server issue..

    You could, if you are always redirecting that page/site to another site, use a .htaccess page to make it even quicker. Or have your ISP adjust the apache config to make it even quicker than that.

    -jason
     
    DopeDomains, Mar 13, 2008 IP
  5. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hi Jason,

    I uploaded several .php files for redirecting to many urls.

    Examples: redirect1.php, redirect2.php, redirect3.php (about 30 of these .php files). I uploaded them to the domain folder where I installed Wordpress.

    I am not familiar with .htaccess and I am afraid that if I touch it I might mess up my sight.
     
    Bohol, Mar 13, 2008 IP
  6. DopeDomains

    DopeDomains Guest

    Messages:
    207
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Do the files do anything other than redirect?

    -Jason
     
    DopeDomains, Mar 13, 2008 IP
  7. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Hi Jason,

    Just redirect, nothing else. (affiliate links, actually)
     
    Bohol, Mar 13, 2008 IP
  8. DopeDomains

    DopeDomains Guest

    Messages:
    207
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #8
    If you weren't ever going to add new links, remove old ones, etc.. I would go for .htaccess for speed. But I think it would be a PITA to manage if you were making weekly changes.. and one mess up and all your links are down till you fix them..

    Otherwise, AFAIK,
    
    <?php
    header('location:http://www.exampledomain.com/go/to.php');
    exit;
    ?>
    
    PHP:
    Is as fast as it gets, and even with a database search first, It get's directed in under a second.

    If it were me, for ease of management I would go with a Db driven single php file that you can use to redirect all your pages.. (and with some fancy html, the world would never be any wiser).. Code up a simple (10 min) back end and your done.

    HTML redirection (at least all the ways I'm familiar with) is going to be slower.. Think about all the times you have seen "If you are not redirected automatically press here".. that is the classic HTML redirection.


    good luck.

    -Jason
     
    DopeDomains, Mar 13, 2008 IP
  9. Bohol

    Bohol Peon

    Messages:
    2,680
    Likes Received:
    75
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi Jason,

    Thank you so much for your input. I really appreciate it. From what you have outlined here, I have come to a conclusion that a .php redirect is more practical than a .html redirection. I wish I could dump all redirection in one database but I am not a hard-core MYSQL programmer so I am doing it manually: one php file per url redirection.

    I just hope that Google would still index a .php file
     
    Bohol, Mar 13, 2008 IP
  10. DopeDomains

    DopeDomains Guest

    Messages:
    207
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #10
    DopeDomains, Mar 13, 2008 IP
  11. Gonzo4u

    Gonzo4u Well-Known Member

    Messages:
    410
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    110
    #11
    Hi! Bohol,

    If you are doing so many redirects for eg. affiliate link then I would suggest you using this technique for secure and faster process.

    Step 1:
    Sales page

    Create you own affiliate link codes where you have an affiliate href link such as:
    www.yoursite.com/redirect.php?aid=aff1
    www.yoursite.com/redirect.php?aid=aff2
    www.yoursite.com/redirect.php?aid=aff3

    Step 2:
    Redirect page(redirect.php)

    Here put in this codes:

    <?PHP
    $aid = $_GET['aid'];
    if ($aid == "") {$link = "http://www.yoursite.com/";} // Default Blank
    if ($aid == "aff1") {$link = "http://www.affiliate1.com/?id=xxxxxxxx";}
    if ($aid == "aff2") {$link = "http://www.affiliate2.com/?id=xxxxxxxx";}
    if ($aid == "aff3") {$link = "http://www.affiliate3.com/?id=xxxxxxxx";}

    header("Location: $link"); // Jump to the hiddden affiliate URL above
    exit();
    ?>

    With this method you not only hide your affiliate links but redirect them quick as there are no other codes on this script except redirect.


    Regards,
    Gonzo
     
    Gonzo4u, Mar 13, 2008 IP