Want to learn about link cloaking so that you can get those nice clean affiliate URLs that you see other sites using?

Cloaking your affiliate links is often the difference between a simple URL like:yoursite.com/recommends/kinsta and a monstrosity like this: https://shareasale.com/r.cfm?b=895364&u=268480&m=5108&urllink=&afftrack=kinstablog

The Kinsta affiliate program links are actually pretty clean – but you get the idea!

To help you get up and running with link cloaking on your WordPress site, we’ll cover three things in this post:

You can click one of the links above to jump straight to a section. Otherwise, let’s dive in!

The Biggest Benefits Of Link Cloaking for Affiliates

Ok, let’s start with the obvious. Cloaking affiliate links is just a lot cleaner and looks better to your visitors, especially non-technical users.

For example, if a user sees that the link goes to https://shareasale.com/r.cfm?b=974656&u=268480&m=5108&urllink=&afftrack= when they think it should go to teepublic.com, they might naturally find that confusing.

Not only does it not give them any information about where they’ll end up, but it also looks quite “scary”, which might make people hesitant to click on it because they think it has a virus or some other nefarious purpose.

On the other hand, if they see yoursite.com/go/kinsta, it’s crystal clear that clicking the link will take them to Kinsta.

When users are more confident that the link they’re clicking is safe, they’ll be more likely to click it, and that means more chances for you to earn a commission.

Beyond that big benefit, there are also benefits when it comes to management and protection against commission theft.

Enjoy Easier Affiliate Link Management

If you’re working with a lot of different affiliate programs, a good link cloaking setup will also make it a lot easier to manage your affiliate links and, if needed, swap them out in the future.

For example, let’s say that you want to send visitors to Kinsta’s affiliate program in a new post that you’re writing. Without link cloaking, you’d have to go log in to your Kinsta affiliate account, grab your affiliate link, and then add it to the post.

However, with a good link cloaking plugin, you can just insert the link straight from the WordPress editor:

How to insert an existing affiliate link
How to insert an existing affiliate link

The more affiliate programs you work with, the more time this will save you.

Then, there’s the situation where one of your affiliate partners changes their link structure. For example, your partner moves from ShareASale to Impact Radius (this happens more often than you think). So what do you do?

Well, one way could be to run a search and replace on your database. But with a link cloaking plugin, you can just update the destination URL for that cloaked link and you’re good to go. That’s a lot faster and less complicated.

Protect Your Affiliate Links From Malicious Replacement

Finally, cloaking your affiliate links can help protect you from some malicious actors and malware that want to steal your commissions.

See, while affiliate links might look they’re just a random mess of numbers, they actually contain incredibly important information. Usually, the only thing linking a click to your site is a few ID numbers in the link.

That means if someone wants to steal the credit for your traffic, all they need to do is swap your affiliate ID number for their own.

While link cloaking won’t protect you from all forms of commission theft, it does make it less trivial for malicious actors to swap your ID for their own.

One Caveat – Make Sure Your Affiliate Program Allows Link Cloaking

In general, cloaking affiliate links is a good strategy. But there is one important thing to pay attention to:

Some affiliate programs do not allow link cloaking.

The most notable example is the Amazon Associates affiliate program, which specifically states that “You will not use a link shortening service, button, hyperlink or other ad placement in a manner that makes it unclear that you are linking to an Amazon Site.”

Most affiliate programs are fine with link cloaking – but you should always double check when in doubt.

How To Cloak Affiliate Links With The ThirstyAffiliates Plugin

The absolute simplest way to cloak affiliate links in WordPress is with a plugin like ThirstyAffiliates.

ThirstyAffiliates comes in both a free and premium version, but the free version should be fine for most people.

Beyond the basic link cloaking functionality, ThirstyAffiliates can also:

  • Organize affiliate links into categories for easy management.
  • Automatically nofollow affiliate links
  • Track affiliate link clicks
  • Automatically add affiliate links to certain keywords (paid feature)
  • Send visitors to different places depending on their geolocation (paid feature)
  • Check affiliate links for 404 errors so that you’re not wasting traffic (paid feature)

It also includes this cool feature that lets you selectively disable cloaking for certain links (like Amazon). This lets you still benefit from improved management without running afoul of Amazon’s rules.

Here’s how to use the plugin to start cloaking affiliate links on your WordPress site.

Step 1: Choose Your Affiliate Link Prefix

Once you’ve installed and activated the ThirstyAffiliates plugin, the first thing that you’ll want to choose is your link prefix.

Your link prefix is the part of your cloaked link that appears immediately after your domain name but before the actual affiliate link slug. For example:

  • yoursite.com/recommends/affiliate-offer
  • yoursite.com/go/affiliate-offer
  • Etc.

To choose your link prefix, go to ThirstyAffiliates → Settings. Then, choose the Link Appearance tab and use the Link Prefix drop-down to either choose one of the suggestions or create your own:

Choose link prefix
Choose link prefix

Further down the page, you can also choose whether to automatically nofollow affiliate links and/or open affiliate links in a new tab.

Step 2: Add Individual Affiliate Links

Once you’ve chosen your link prefix, go to ThirstyAffiliates → New Affiliate Link to add your first cloaked affiliate link.

At the top, add a title. This will help you remember the link and insert it in content, so make it relevant to the link. Then, add the destination affiliate link into the Destination URL box:

Add a new affiliate link

If you’re using Kinsta’s affiliate program, you can easily make your destination affiliate link by clicking on the “Make affiliate link” button on the bottom left of our dashboard. You can link to anywhere on the entire Kinsta site.

Affiliate dashboard
Affiliate dashboard

To organize your links, you can use the Link Categories box to create new categories or assign existing categories, just like you would with a regular post:

Add a link category for organization
Add a link category for organization

And you can also use the Link Options box to override the defaults from the plugin’s settings. For example, if you turned on the nofollow feature in the plugin’s settings, nofollow will automatically be turned on in the Link Options box. But, if desired, you could override this and turn nofollow off for this specific link:

Configure link options
Configure link options

Once you’re done configuring your link, click the Save Link button.

Once you save your link, you’ll see a new option for Cloaked URL. By default, ThirstyAffiliates will use the title of your link for the slug. But if you want to manually change the slug, you can click the Edit Slug button:

Edit link slug
Edit link slug

As an alternative method for adding new affiliate links, you can also use the Quick Add Affiliate Link button in the WordPress TinyMCE editor to add a new affiliate link that way:

Quick add a new link from the TinyMCE editor
Quick add a new link from the TinyMCE editor

Once you click that button, you’ll be able to add the same type of information in a popup:

Quick add new link interface
Quick add new link interface

This is convenient when you find yourself needing to add a new affiliate link while you’re in the middle of writing a post.

Step 3: Insert Cloaked Affiliate Links In WordPress Content

To quickly insert affiliate links in your content, ThirstyAffiliates also gives you an Add Affiliate Link button. When you click that, you’ll be able to search for affiliate links by name and easily add them to your content:

How to insert an existing affiliate link
How to insert an existing affiliate link

ThirstyAffiliates will automatically use the link title as the anchor text, but you can edit that if desired.

If you’re using the new WordPress block-based editor (Gutenberg) in WordPress 5.0 and onwards, ThirstyAffiliates doesn’t offer a direct Gutenberg integration at the time that we’re writing this post (they made add one soon – so we recommend double checking).

Even without a direct Gutenberg integration, you can still manually add your cloaked affiliate links. Or, you can access the ThirstyAffiliates buttons from the Classic block:

Inserting an affiliate link from a Classic block in the block-based editor
Inserting an affiliate link from a Classic block in the block-based editor

Reasons To Consider ThirstyAffiliates Pro

Everything that we showed you above is using the free version of ThirstyAffiliates from WordPress.org. However, there are a number of helpful features that are available in the premium version. We’ll feature some of them below – but you can see the full list here.

Probably the most sought-after feature is automatic affiliate link insertion. With this feature, you can automatically link certain keywords to affiliate links no matter where they show up on your site.

For example, you could automatically link the word “Kinsta” to your Kinsta affiliate link. You can also set up rules to avoid over-linking, like “only link the word a maximum of two times per post and randomly choose which instances to link”:

Automatically link keywords to affiliate links
Automatically link keywords to affiliate links

You can also choose which post types to enable autolinking on, as well as other site-wide settings.

You can also send people to different URLs based on their location, which is helpful if your affiliate program has separate localized sites:

How to geotarget your affiliate links
How to geotarget your affiliate links

And if you are using the Amazon Associates program, you can import products from Amazon (remember – you can selectively uncloak links to avoid breaking policies).

How To Cloak Affiliate Links In WordPress Without A Plugin

If you don’t want to use a plugin, it’s also possible to cloak affiliate links in WordPress without a plugin. If you don’t have very many affiliate links, this is a viable option. But it gets a bit unwieldy if you’re trying to cloak lots of different links, and it requires you to edit a file on your server every time you want to add a new affiliate link.

This method pulls from these GitHub code snippets put together by the Yoast SEO team – so full credit to them for putting this together.

In order to follow these steps, you’ll need to be able to connect to your site via FTP. If you’re hosting with Kinsta, you can follow this guide to connect to your WordPress site via SFTP.

Step 1: Create A New Folder On Your Server

Once you’ve connected to your site via FTP, create a new folder in the root folder of your site. The name of this folder will serve as the base redirect prefix for your cloaked affiliate links. You’ll likely want to name it something like:

  • go
  • recommends
  • out
  • Etc.

Below, you can see that we’ve created a new folder name out:

Create a new folder on your server
Create a new folder on your server

Step 2: Upload index.php File

Inside that new folder, create a new file called index.php and add the code snippet from Yoast SEO’s GitHub.

It should look like this:

Add the index.php file along with the code from GitHub
Add the index.php file along with the code from GitHub

Step 3: Add Your Affiliate Links In redirects.txt File

Next, you need to create another new file in that folder called redirects.txt. This file is where you’ll add:

  • The link slug for each individual affiliate link
  • The destination URL for each individual affiliate link

The format is:


Add each affiliate link on its own line. For example:


To handle edge cases, you should also make sure that the first line is this:


Put together, here’s what it might look like:

Add the redirects.txt file
Add the redirects.txt file

Step 4: Use Robots.txt to Block Crawlers

To stop Google and other search engines from following your redirects, you should add the following rule to your site’s robots.txt file:

Disallow: /folder-name/

Where “folder-name” is the actual folder that you created in step 1.

To learn how to edit your robots.txt file, check out our full WordPress robots.txt guide.

How To Use Cloaked Affiliate Links

To link to your cloaked affiliate links, use this formula:


For example:


Start Cloaking WordPress Affiliate Links Today

Cloaking affiliate links on your site is just generally a good practice. As long as your affiliate program allows it (which most do), cloaking your affiliate links:

  • Is better for visitors because your links look more trustworthy and make it clear where the visitor will end up.
  • Makes it easier for you to manage your affiliate links and, if needed, change them in the future.
  • Protects you from malicious actors who try to swap your affiliate ID with their own.

For the easiest and most convenient way to cloak affiliate links, you can use the freemium ThirstyAffiliates plugin. Or, if you’re more of a DIY type, you can also set up your own system using the code snippets from Yoast SEO that we detailed.

Do you have any other questions about how to cloak affiliate links on your WordPress site? Let us know in the comments!