PHP redirect - Need Help Please

4 replies
Not sure if this is the right forum to ask this in or not, but I am having a little trouble building a PHP redirect. I went online to find it but the pages I found are a bit confusing. I had the code but don't remember where I put it and can't spend a week looking for it. So I am hoping someone can give me the code to create a redirect to another page on the web from my site to an affiliate product.
#php #redirect
  • Profile picture of the author Johnny Slater
    Is this what your looking for?

    Code:
     
    header("Location: http://somesite.com/affiliatelinkhere");
    Signature

    {{ DiscussionBoard.errors[4883171].message }}
    • Profile picture of the author timpears
      Originally Posted by Johnny Slater View Post

      Is this what your looking for?

      Code:
       
      header("Location: http://somesite.com/affiliatelinkhere");
      I think so. Thanks.
      Signature

      Tim Pears

      {{ DiscussionBoard.errors[4883345].message }}
  • Profile picture of the author EdwinBrownJr
    Originally Posted by timpears View Post

    Not sure if this is the right forum to ask this in or not, but I am having a little trouble building a PHP redirect. I went online to find it but the pages I found are a bit confusing. I had the code but don't remember where I put it and can't spend a week looking for it. So I am hoping someone can give me the code to create a redirect to another page on the web from my site to an affiliate product.
    STEP ONE: Optional - create a new directory on your site to store all the redirects. I chose to create a directory called "recommends".

    STEP TWO: Create a file called myprogram.php where myprogram is the name of the program you are promoting (e.g. ebay.php in the above example).

    STEP THREE: Open this file in a text editor such as notepad

    STEP FOUR: Copy and paste the following exact text in the file:
    PHP Code:
    <?php header("Location:http://www.youraffiliatelink.com"); exit(); ?>
    STEP FIVE: Replace youraffiliatelink.com with the affiliate link that you are promoting.

    Important - do not remove the quotes around this link and do not remove the word Location: and do not add or remove spaces - only replace the URL and nothing else.

    STEP SIX: Upload this file to your website

    STEP SEVEN: If your file is called myprogram.php and you uploaded it to a directory called "recommends" your URL will be:
    http://www.yoursite.com/recommends/product.php



    Step EIGHT: When linking to your affiliate link, you can now use:

    <a href="http://www.yoursite.com/recommends/product.php">affiliate link</a>
    {{ DiscussionBoard.errors[4883401].message }}
  • Profile picture of the author Istvan Horvath
    And if you want a permanent (301) redirect, use this:

    Code:
    <?php
    header( "HTTP/1.1 301 Moved Permanently" ); 
    header( "Location: http://www.new-url.com" ); 
    ?>
    Signature

    {{ DiscussionBoard.errors[4883431].message }}

Trending Topics