9 ways to hide affiliate links

These codes are useful for hiding the affiliate links. However, please read the affiliate program terms of service, so that you won’t go against it.

For all except the last way (.htaccess redirect), create the respective file for each affiliate link with the code for the chosen redirect style. Replace ‘http://your-affiliate-link-goes-here’ with the URL of the affiliate link.

For example, if you choose to use the PHP redirect, first create a PHP file. Copy and paste the PHP redirect code into that file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL.

Every time you want to link to the affiliate link, just link to that file.

You have to create new file for each affiliate link.

  1. HTML redirect
  2. 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    
    <html>
    <head>
    <title>HTML Redirect</title>
    <meta http-equiv="refresh" content="0; url=http://your-affiliate-link-goes-here">
    </head>
     
    <body>
    Please wait. Redirecting...
    </body>
    </html>
  3. PHP redirect
  4. 1
    2
    3
    
    <?php
    header("Location: http://your-affiliate-link-goes-here");
    ?>
  5. ASP redirect
  6. 1
    2
    3
    4
    
    <%@ Language=VBScript %>
    <%
    Response.AddHeader "Location","http://your-affiliate-link-goes-here"
    %>
  7. ASP.NET redirect
  8. 1
    2
    3
    4
    5
    6
    
    <script runat="server">
    private void Page_Load(object sender, System.EventArgs e)
    {
    Response.AddHeader("Location","http://your-affiliate-link-goes-here");
    }
    </script>
  9. Coldfusion redirect
  10. 1
    
    <.cfheader name="Location" value="http://your-affiliate-link-goes-here">
  11. JSP redirect
  12. 1
    2
    3
    4
    
    <%
    response.setHeader( "Location", "http://your-affiliate-link-goes-here" );
    response.setHeader( "Connection", "close" );
    %>
  13. cgi Perl redirect
  14. 1
    2
    
    $q = new CGI;
    print $q->redirect("http://your-affiliate-link-goes-here");
  15. Ruby on Rails redirect
  16. 1
    2
    3
    
    def old_action
    redirect_to "http://your-affiliate-link-goes-here"
    end
  17. Apache .htaccess on Linux
  18. Add this code to the end of .htaccess file. Replace ‘http://your-affiliate-link-goes-here’ with the affiliate link URL. To have more than one affiliate link, just add another RewriteRule.

    1
    2
    
    RewriteEngine on
    RewriteRule ^affliate.php$ http://your-affiliate-link-goes-here [R]

If you liked this post, these other posts might also be interesting to you:

Spread/Promote this post.

Digg | Del.icio.us | Stumble | Y! MyWeb | Y! Buzz | Fave It! | Reddit
Tags: , , , , , , , , ,
Category: Blog Tips, PHP  |  Comment (RSS)  |  Trackback

8 Comments

  1. Jeff:

    The question is WHY would you want to hide the affiliate link? I’m sure there is a good reason, but it escapes me.

  2. kipram:

    Nice Blog Design, whre i can get this theme

    kiprams last blog post..Cara Gampang Mengalahkan SEO Master

  3. selinap.com:

    I design it myself.

  4. selinap.com:

    Jeff: It is not the matter why we should hide the affiliate links. What important is that we could do it.

  5. hanep:

    Jeff: what would you do if you found the link you’ll be redirect is affiliate link?. that’s the answer for your question.

    i don’t remember the name, but there’s a wordpress plugin that can hide the aff links, and it works.

  6. syuxx:

    i always use iframe to cloak my affliate link. then i encrypt the code so when they view the source, all they see is just the code.

  7. How to hide your Affiliate Link | Thumlog!:

    [...] also has write a nice tutorial on How to Hide affiliate link. You might be interested to read the 9 ways to hide affiliate links tutorial by Selinap. Subscribe to comments Comment | Trackback | Post Tags: affiliate program, [...]

  8. htaccess redirect:

    Don’t forget to mention that PHP redirectional scripts work just has good as actual redirect codes. :)

Leave a comment