This tutorial will show you how to cloak your affiliate links using BunnyCDN. By cloaking your links, you can hide the original destination of the link, making it harder for users to block or remove your affiliate tracking code. This will help to increase your earnings and improve the aesthetics of your website. 😍
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.
- Easy to track logs.
- Off-load ‘Affiliate’ links to BunnyCDN server to avoid Single Point of Failure. Your link will continue to work even if your main site goes down.
There are two ways to set up redirection or link cloacking in BunnyCDN.
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
- 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
- Set Origin URL to
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,
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
- Condition Matching: Match Any
- IF Conditions: Request URL (Match Any)
- Trigger path:
- 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, I strongly recommend using the Storage option as described below.
Method #2. Using Cloud Storage Zone
Step 1. Login to BunnyCDN Dashboard, add a new Storage zone.
Step 2. Complete Basic Details
- Name: Enter any unique name, for example
- 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
gulshan-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
Step 7. Point DNS record to your Pull Zone hostname
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 name:
- Header value:
- Condition Matching: Match Any
- This rule will apply
x-robots: nofollow, noindexheader 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
So we need redirection from our custom hostname to affiliate path.
Steps to achieve it
- Add a new directory with the brand name, for example
bunnycdnwhich will slug for its referral link.
(always prefer naming in the small letter, all storage object name is case-sensitive)
- Next, add an
- The URL will be accessible over
- or with slash
- It will redirect to the target brand affiliate path.
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.
1 thought on “Cloak Affiliate links with BunnyCDN”
Thanks, Gulshan sir for some new information on affiliate link redirection.