Cloak Affiliate links with BunnyCDN

Link cloaking is not always hiding or illegal but a process of doing the URL redirection for efficient management.

cloack affiliate links with BunnyCDN

Advantages of doing link cloaking

  • It helps in turning long affiliate URL to short, sweet and memorable.
  • It helps in managing all affiliate programs links at one place.
  • It helps in tracking click efficiently.
  • It looks more professional, branded than sharing 3rd-party domain.
  • It improves e-mail delivery.
  • It is easier to nofollow all links.
  • It is also possible to do geo-redirection with cloaking.
  • It helps in maintaining a kind of transparency with visitors.

Why use BunnyCDN for Link Cloaking?

A plugin like Affiliate Link Lite works only works with traditional WordPress running over PHP and MySQL server.

In case you are running a Serverless site, Static WordPress or HTML site or maybe using the old-fashioned Google Blogspot platform, you can let BunnyCDN professionally handle all your redirection.

There are two ways to set up redirection or link cloacking in BunnyCDN.

  1. Using the Edge Rule feature in a Pullzone
  2. Using Cloud Storage zone and linked Pull zone

Method 1. Using the Edge Rule

BunnyCDN offers a powerful edge rule feature called “Redirect to URL“. We can use it to set up redirection based on conditional path, country, etc.

  • For example, when the user will visit https://affiliate.gulshankumar.net/some-brand/
  • They will go to your defined affiliate link for that particular brand.

Let’s see how it can be done.

Step 1. Add a Standard Tier new Pullzone

  • Enter unique pull zone name, for example affiliate-partner 
  • Set Origin URL to https://www.example.com/404

Step 2. Select all Pricing Zones for the fastest redirection

Step 3. Skip the instructions about setup, we are going to do it differently.

Step 4. Add a subdomain as custom hostname in Pull zone

  • For example, affiliate.gulshankumar.net

Step 5. Point subdomain using CNAME record to the Pullzone hostname

  • If you’re already using nameservers of BunnyCDN, it automatically has done.
  • If you’re using Cloudflare managed DNS, then create there A CNAME and keep proxy turned off.

Step 6. Install SSL Certificate and force HTTPS

Step 7. Add a new Edge Rule

Edge Rules allow you to fine-tune how your pull zone behaves based on the request path as well as set up some more advanced routing and features. To get started, you can have a look at our Edge Rule Knowledge Base where we provide useful articles to help you set things up.

BunnyCDN
  • Action: Redirect to URL
  • Description: Enter a memorable name for edge rule. Example: BunnyCDN Affiliate link
  • Redirect URL: Enter the affiliate link https://bunnycdn.com/?ref=example
  • Condition Matching: Match Any
  • IF Conditions: Request URL (Match Any)
  • Trigger path: */bunnycdn*
  • Save Edge Rule

Repeat this process for creating cloaked link for all affiliated brand.

Keep in mind, in one pull-zone you can have maximum 20 edge rules. If you have more than twenty links, we strongly recommend using the Storage option as described below.

Method #2. Using Cloud Storage Zone

BunnyCDN offers inexpensive cloud Storage services that we can use to host HTML pages for creating cloaking affiliate links. We can do redirection using JavaScript and meta-refresh as the fallback.

Step 1. Login to BunnyCDN Dashboard, add a new Storage zone.

Step 2. Complete Basic Details

  • Name: Enter any unique name, for example gulshan-aff
  • Main Storage Region: Europe (Choose any nearest from you)
  • Enable GEO Replication in all regions (Optional step for faster redirection)
  • Click on + Add storage zone button

Step 3. Connect your Storage to a new Pull zone

Step 4. Enter new Pull zone information

  • Namegulshan-aff (It can be different than storage name)
  • Choose Standard Tier (It allows serving data from all PoPs)
  • Select all pricing zones for the better experience
  • Then, click on +1 Add Pull Zone

Step 5. Skip instructions

Step 6. Add custom hostname for Pull Zone of Storage Zone gulshan-aff

Step 7. Point DNS record to your Pull Zone hostname

For example

Record typeNameValue
CNAMEaffiliategulshan-aff.b-cdn.net

If you use Cloudflare DNS, keep Gray cloud to have DNS only mode.

If you’re using BunnyCDN DNS, no additional action is required.

Step 8. Enable Free SSL and Force SSL (HTTPS) in one click

Step 9. Add x-robots: noindex, nofollow header for all Affiliate links

  • Action: Set Response Header
  • Description: SEO-Friendly Affiliate links
  • Header namex-robots
  • Header valuenoindex, nofollow
  • Condition Matching: Match Any
  • This rule will apply x-robots: nofollow, noindex header for all affiliate links.

Step 10. Go back to Storage which you created in last step six.

Now let say the Brand name is BunnyCDN and your affiliate link is https://www.bunnycdn.com/?ref=example

So we need redirection from our custom hostname to affiliate path.

  • From https://affiliate.gulshankumar.net/bunnycdn
  • To https://www.bunnycdn.com/?ref=example

Steps to achieve it

  • Add a new directory with the brand name, for example bunnycdn which will slug for its referral link.

(always prefer naming in the small letter, all storage object name is case-sensitive)

  • Next, add an index.html file for redirection with meta refresh and JavaScript. Make sure to modify link as per your use case.
<!DOCTYPE HTML>
<html lang="en-US">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="refresh" content="0; url=https://bunnycdn.com/?ref=example">
        <script type="text/javascript">
            window.location.href = "https://bunnycdn.com/?ref=example"
        </script>
        <title>Page redirection</title>
    </head>
    <body>
        If you are not redirected automatically, follow this <a href='https://bunnycdn.com/?ref=example'>link</a>.
    </body>
</html>
  • The URL will be accessible over https://affiliate.gulshankumar.net/bunnycdn
  • or with slash https://affiliate.gulshankumar.net/bunnycdn/
  • It will redirect to the target brand affiliate path.

Important Informations

Step 11. Avoid caching redirect response in the in browser

How to create bulk redirection?

If you want to setup 100 affiliate links, create 100 folders and its index.html file at your PC and upload using your favourite FTP application. That’s the fastest way.

I recommend you do the first few tests before final deployment. Once deployment finishes, always keep backup of all folders to make changes in future easily by re-uploading.

How to avoid Browser Cache and still maintain Edge cache?

Go to Pull Zone, General, Browser Cache Expiration Time, set the Browser Cache expiration time to Override: Do not cache. Or, you can set min 30 seconds. That should also work great. Remember, for changeable link like this it is better to keep the lowest TTL for browser.

What is technical difference in setting up redirection via Edge Rule and Storage?

The edge rule method is quick and easy for 301 redirections, limited to 20 edge rules per Pull Zone. The edge rule method is slightly faster.
The Cloud Storage method allows you to serve unlimited HTTP 302 redirections with greater control over HTML coding.

When to purge Cache?

You can update your affiliate link anytime in future, so purging cache is required. Regardless of both method, if you make any changes in Storage or Pull Zone make sure to purge the cache.

How to test either my Redirection is working or not

Open terminal or CMD and type curl -I https://example.com/brand/ this will help in checking HTTP Status code and overall response. You can also use the Chrome Developer tool for analysis.

Can I use Perma Cache with Storage method?

Yes. It can help in redirecting faster when uncached.

Any question? Please ask at Gulshan Forum.

Leave a Comment