How to Cloak Affiliate Links

21 replies
Hey guys,

I want to cloak/redirect my affiliate links ...not so much to hide that it's an affiliate link but to shorten the link b/c my customers will have to type it into their browser (not click).

I know how to manually do .php redirects but I'd rather have a page with no extension. So instead of example.com/redirect.php I want it to be example.com/redirect


How would you recommend I do this? I don't want to use a wordpress plugin. I'd rather do this myself and not rely on a plugin.

What's the correct way? Do I do a Cpanel redirect? Create a page and put something in the header? ...and is there something I should do on the page so Google doesn't hate me for having affiliate links?

(Ideally I want to easily write simple code on a page, drop it in my websites files, and it redirects ...or do this in cPanel)...

What would you experienced guys recommend Thanks a lot
#affiliate #cloak #links
  • Profile picture of the author PaidAllDay
    just create subfolders and drop a file called index.php into that folder:

    example.com/redirect/index.php

    Inside that index.php file put this code:

    Code:
    <?php
       header( 'Location: http://www.affiliatelink.com' ) ;
    ?>
    then you can link to example.com/redirect/ and it will redirect.

    That's really all there is to it... However, I would add that different redirects accomplish different things. A php redirect will show that location as the referrer where a javascript or meta refresh will show the referrer as the link clicked before yours.

    Personally I like to use both a Meta Refresh and JS redirect like this:

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
      <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
    	<title></title>
    	<meta http-equiv="refresh" content="0; url=http://www.affiliatelink.com">
    	<script type="text/javascript">
    		<!--
    		location.replace("http://www.affiliatelink.com");
    		//-->
    	</script>
    </head>
    <body>
    </body>
    </html>
    That way it cloaks the referrer and refreshes as fast as possible. A DMR or double meta refresh will add an extra layer of security to that (google it).
    {{ DiscussionBoard.errors[8128434].message }}
    • Profile picture of the author Michael71
      The meta tag will redirect before the JS would get executed...

      Better just use JS or PHP

      Originally Posted by PaidAllDay View Post

      just create subfolders and drop a file called index.php into that folder:

      example.com/redirect/index.php

      Inside that index.php file put this code:

      Code:
      <?php
         header( 'Location: http://www.affiliatelink.com' ) ;
      ?>
      then you can link to example.com/redirect/ and it will redirect.

      That's really all there is to it... However, I would add that different redirects accomplish different things. A php redirect will show that location as the referrer where a javascript or meta refresh will show the referrer as the link clicked before yours.

      Personally I like to use both a Meta Refresh and JS redirect like this:

      Code:
      <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
        <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
      	<title></title>
      	<meta http-equiv="refresh" content="0; url=http://www.affiliatelink.com">
      	<script type="text/javascript">
      		<!--
      		location.replace("http://www.affiliatelink.com");
      		//-->
      	</script>
      </head>
      <body>
      </body>
      </html>
      That way it cloaks the referrer and refreshes as fast as possible. A DMR or double meta refresh will add an extra layer of security to that (google it).
      Signature

      HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
      ---
      Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu

      {{ DiscussionBoard.errors[8128531].message }}
      • Profile picture of the author PaidAllDay
        Originally Posted by Michael71 View Post

        The meta tag will redirect before the JS would get executed...

        Better just use JS or PHP
        Hey Michael, the point of doing both is because meta refreshes can sometimes be slow, having the JS as a backup will make sure it redirects as quickly as possible. PHP would be the fastest, but as I mentioned it will show the referrer as your page, which you may not want in some cases.
        {{ DiscussionBoard.errors[8128891].message }}
    • Profile picture of the author fabuloso
      Originally Posted by PaidAllDay View Post

      just create subfolders and drop a file called index.php into that folder:

      example.com/redirect/index.php

      Inside that index.php file put this code:

      Code:
      <?php
         header( 'Location: http://www.affiliatelink.com' ) ;
      ?>
      then you can link to example.com/redirect/ and it will redirect.

      That's really all there is to it... However, I would add that different redirects accomplish different things. A php redirect will show that location as the referrer where a javascript or meta refresh will show the referrer as the link clicked before yours.

      How did you know that your affiliate link will work? Is there ways to track whether it works or not? I'm afraid that we will not get paid if the link does not work.
      {{ DiscussionBoard.errors[8595925].message }}
      • Profile picture of the author lisawilliam99
        if we done this, how can i take some benefits
        {{ DiscussionBoard.errors[8785562].message }}
  • Profile picture of the author David V
    Here's another decent clean way on github to cloak your links, with a quick how to by Yoast.
    How to cloak your affiliate links
    {{ DiscussionBoard.errors[8128645].message }}
    • Profile picture of the author RobinInTexas
      Originally Posted by David V View Post

      Here's another decent clean way on github to cloak your links, with a quick how to by Yoast.
      How to cloak your affiliate links
      I use the script by Yoast, and on a shared server, I use a single "redirects.txt" file shared by all the sites on my host. Makes things much easier.
      Signature

      Robin



      ...Even if you're on the right track, you'll get run over if you just set there.
      {{ DiscussionBoard.errors[8784131].message }}
  • Profile picture of the author Michael71
    Use a blank referrer "service" or PHP to remove the http referrer...
    Signature

    HTML/CSS/jQuery/ZURB Foundation/Twitter Bootstrap/Wordpress/Frontend Performance Optimizing
    ---
    Need HTML/CSS help? Skype: microcosmic - Test Your Responsive Design - InternetCookies.eu

    {{ DiscussionBoard.errors[8129488].message }}
  • Profile picture of the author TheWebGuy
    Super helpful stuff guys. Thank you very much.

    Now I'm not a programmer or advanced coder by any means ...so if I just went into Cpanel and used the redirect feature in Cpanel ...would that accomplish the same thing? And would that be a proper way to to handle my redirects? (my cpanel gives me the option to do a permanent and temporary redirect ...don't know which to pick).
    {{ DiscussionBoard.errors[8130764].message }}
    • Profile picture of the author PaidAllDay
      Originally Posted by TheWebGuy View Post

      Super helpful stuff guys. Thank you very much.

      Now I'm not a programmer or advanced coder by any means ...so if I just went into Cpanel and used the redirect feature in Cpanel ...would that accomplish the same thing? And would that be a proper way to to handle my redirects? (my cpanel gives me the option to do a permanent and temporary redirect ...don't know which to pick).
      It's really not much programming to do a PHP redirect. You just open up a text file and drop one line of code in it. If you use use subfolders like I suggested and an ftp program you can keep track of everything easier.

      However, should you decide to go the cPanel route it doesn't matter which one you pick. It's going to write your redirect into an .htaccess file as a 301 or 302 depending on whether you choose permanent or temporary. Either one works fine. I would go with 301 because that is more common... so to answer your question "Permanent". I believe that is better for SEO purposes as well as it tells search engines that the content is moved to a new location and the old file does not need to remain in the index. Not really relevant to what you are doing, but worth noting on this forum.
      {{ DiscussionBoard.errors[8130934].message }}
      • Profile picture of the author Cram
        You could always make a qr code, so users don't have to type the url in.

        and for shortening your url you could always use a PaidAllDay technique and instead of using the aff link on your
        site.com/offer/index.php
        I like using tracking url, this would help with cloaking/blank referrer aswell.
        Code:
        <?php
           header( 'Location: https://bevomedia.com/direct-link/FASDFAS...' ) ;
        ?>
        {{ DiscussionBoard.errors[8132019].message }}
  • Profile picture of the author lordspace
    If you are running WordPress you can try the Redirection plugin
    Signature

    Are you using WordPress? Have you tried qSandbox yet?

    {{ DiscussionBoard.errors[8132187].message }}
  • Profile picture of the author TheHust
    HTaccess would probably be best, plus it saves creating lots of different files.

    Just stick something like this in .htaccess

    Redirect 301 /afflink1 http://www.afflink1.com
    Redirect 301 /afflink2 http://www.afflink2.com
    Signature

    Link Wrangler

    {{ DiscussionBoard.errors[8598997].message }}
    • Profile picture of the author tonyla
      If you have webhosting that uses softaculous there is a script called yourls.
      Great program.
      I use it all the time.
      Install in a sub dir of your main domain.
      Suppose your domain name was moneylink.com install in a subdirectory say viplinks. Then when you cloak it give it a name like am
      now your url is http://moneylink.com/viplinks/am

      cool think about this it will track number of hits and where the hits are coming from.
      {{ DiscussionBoard.errors[8604056].message }}
  • Profile picture of the author mitz
    Here is a video showing how to do a php redirect. I also like the idea of using JavaScript but I do not mind showing a referrer as it redirects really quickly.

    Signature

    Have a great day!
    Making money online by building one Wordpress Website at a time.

    {{ DiscussionBoard.errors[8615178].message }}
  • Profile picture of the author wordpressguru
    But why wouldn't you want to use a plugin? Simple URLs is working great! Give it a try.
    {{ DiscussionBoard.errors[8624013].message }}
  • Profile picture of the author duplication
    use short url or google url shortner. Paid versions will let track many details
    {{ DiscussionBoard.errors[8729153].message }}
  • {{ DiscussionBoard.errors[8729971].message }}
  • Profile picture of the author digitalsmart
    1.Create a folder from where you’ll serve your redirects, I use /out/.
    2.Block the /out/ folder in your domains robots.txt file by adding:
    Disallow: /out/
    3.Use a script in your redirect folder to redirect to your affiliate URLs
    {{ DiscussionBoard.errors[8780944].message }}
  • Profile picture of the author softwarewarden
    Originally Posted by TheWebGuy View Post

    Hey guys,

    I want to cloak/redirect my affiliate links ...not so much to hide that it's an affiliate link but to shorten the link b/c my customers will have to type it into their browser (not click).

    I know how to manually do .php redirects but I'd rather have a page with no extension. So instead of example.com/redirect.php I want it to be example.com/redirect


    How would you recommend I do this? I don't want to use a wordpress plugin. I'd rather do this myself and not rely on a plugin.

    What's the correct way? Do I do a Cpanel redirect? Create a page and put something in the header? ...and is there something I should do on the page so Google doesn't hate me for having affiliate links?

    (Ideally I want to easily write simple code on a page, drop it in my websites files, and it redirects ...or do this in cPanel)...

    What would you experienced guys recommend Thanks a lot
    use mod_rewrite to redirect the urls to the correct locations is one way
    {{ DiscussionBoard.errors[8785367].message }}

Trending Topics