How to Cloak Affiliate Links Without Plugin in WordPress?

In this article, you will learn how to cloak affiliate links without plugins on a WordPress website using .htaccess redirection

You will also learn why it is important to cloak affiliate links.

When you join an affiliate program as an affiliate, you are provided with a URL containing your unique referral code. This URL or affiliate link containing your referral code helps track your sales.

If you have heard the term cloaking for the first time and what it does, don't worry. This tutorial will help you easily cloak your affiliate links without using plugins.

Let's get started.

Note: This article contains affiliate links. When you click an affiliate link and make a purchase, we get a small compensation at no cost to you. See our Privacy Policy and Disclaimer for more info.

Cloak Affiliate Links Without Plugin

Why Should You Cloak Affiliate Link?

Affiliate link cloaking emerges as an important practice for crafting custom links for your audience. Doing this makes a short, memorable, and brandable link.

Thus, cloaking links entails the transformation of lengthy, ugly, and complex URL strings into manageable, trustworthy, and branded links.

Below, I have mentioned some key benefits of cloaking affiliate links.

Enhanced Trust and Click-Through Rates

Trust serves as the cornerstone of effective marketing. An affiliate link, once cloaked, looks more professional and credible.

If you look at the above link, it looks long, ugly, and dirty. It needs more trust. Will your site visitors click such links? It is highly unlikely.

Whereas, if you shorten the link as shown below, your visitors are more likely to click on it.

Thus, shortening the link makes it look more branded and trustworthy. It will result in higher CTR and conversion in terms of affiliate sales.

Prevention of Commission Theft

The straightforward construction of standard affiliate URLs can be an open invitation to unscrupulous entities aiming to hijack or overwrite your hard-earned commissions.

Thus, you need to prevent it by cloaking your affiliate link.

By cloaking links:

  • You shield your rightful earnings from being usurped by affiliate link tampering.
  • The complexity of the cloaked URL thwarts most attempts at commission interception, preserving your income.

Boost in SEO Efforts

Uncloaked affiliate links can be misconstrued by search engines as spam or dubious content, thereby:

  • Compromising a website's standing within search algorithms,
  • Undermining the credibility established with search engines,
  • Leading to possible penalization and deterioration of search result placement.
  • Affiliate link cloaking ensures that these links are perceived as internal or valuable content-based links, contributing to:

  • A more polished and SEO-friendly website architecture,
  • Improved link juice flow and ranking potential,
  • Strengthened domain authority and search engine trust.
  • What is Affiliate Link Cloaking?

    Link cloaking is a technique used for shortening long affiliate links. Usually affiliate links are long and ugly to look.

    By shortening affiliate link by cloaking it looks branded and also results in higher Click-Through-Rate (CTR).

    See this example.

    A traditional affiliate link look like this-

    We can shorten the above link by using link cloaking method to make it look like a branded URL as shown below-

    Benefits of Using Link Cloaking

  • As mentioned above, link cloaking shortens the affiliate link, and the link looks more branded to your user. Users are more likely to click on this branded URL instead of a long affiliate link, increasing the click-through rate (CTR).
  • It allows you to mask your unique affiliate ID. Masking affiliate ID makes it difficult for anyone to use malware to replace your unique affiliate link. Thus, you preserve your commission.
  • Now, you can easily manage all your affiliate links by placing them under one folder.
  • If you actively promote your affiliate campaign by sending emails to your users, cloak your affiliate link to land your emails in the inbox instead of the spam folder.
  • Cloak Affiliate Links Using .htaccess Redirection

    STEP 1: Decide On Your URL Slug

    You can use any of these URL slug, for example,

    • /affiliate/, 
    • /go/,
    • /refer/,
    • /out/ or
    • /recommended/
    • /recommends/

    To do this you will need to create a folder in your root directory.

    Login to your cPanel and create a folder (select any one of the above example). For example, you can create a folder - 'go' under public_html folder.

    Now your affiliate link will look like this-

    STEP 2: Prepare Related URL

    In this step you will need to compile a list of related URL for all your affiliate links. For example, if your affiliate link is

    then, you need to create a related URL for the above affiliate link as shown below.

    Repeat the same process for all of your affiliate links.

    STEP 3: Modify .htaccess File

    In this step we will have to modify the .htaccess file which is located under public_html folder. If you are not seeing it then it might be possible that the file is kept hidden by default.

    You can see the hidden .htaccess file by selecting Settings in File Manager.

    Here, you have to select the check box with the option Show Hidden Files (dotfiles). See the image given below.

    Enable hidden files in File Manager

    Enable hidden files in File Manager

    .htaccess file

    .htaccess file

    Now open the .htaccess file and add all the affiliate links as shown below-


    Redirect 302 /go/bluehost

    Redirect 302 /go/siteground

    Redirect 302 /go/mythemeshop

    In the above example, you can see that I have used 302 redirection and added my affiliate link prefix as /go/.

    After the affiliate link prefix /go/, you're now required to add your destination (original) link.

    Now, whenever a users clicks on my affiliate link -, he will be redirected to the Siteground website. And, if he/she decides to purchase a hosting plan from Siteground, I would earn affiliate commission.

    Please remember that you should not modify the existing entries of the .htaccess file otherwise you could get errors on your website.

    That's it, this is how you can add short URL to replace the default long, ugly affiliate link provided by the affiliate network or program.

    Note: Whenever you modify the .htaccess file always make it a habit to keep a copy of it at a safe place in case something goes wrong. I will also advise you to take a complete backup of your website before you implement the above method.

    What is a 302 redirect?

    A 302 status code is commonly referred to as “temporarily moved.” This redirect doesn’t carry or pass the link value to the new URL. What it does do is redirect your site visitors into another web page temporarily.

    STEP 4: Modify Robot.txt File

    In this step you will need to prevent Google from indexing your cloaked URLs. To do this we will need to modify the robot.txt file.

    If you are using Yoast SEO plugin in your site, then go to SEO >> Tools and select File editor. Here you can modify the robot.txt file. Add the following line in robot.txt file.

    User-agent: *
    Disallow: /go/

    Now let's move on to the FINAL step.

    STEP 5: Add Cloaked uRL

    In the final step you will need to replace your affiliate URLs with the newly created cloaked URLs. Find all the affiliate URLs in your blog posts and replaced it with cloaked URLs one by one. 

    Should I nofollow affiliate links? Yes, absolultely.

    If you are not adding nofollow to your affiliate links then you are doing a big mistake by leaking link juice to the affiliate product you are promoting.

    Thus, you must also add rel=”nofollow” to prevent leaking PageRank to the affiliate advertiser. 

    It will take time if you have many blog posts but once done it will worth your time.

    This manual process of cloaking affiliate link is very robust and fast unlike WordPress plugins which does the similar work but may slow down your website.

    Some affiliate program also provide option to cloak the affiliate link. You can cloak the link from the affiliate website itself.

    For example, A2 Hosting affiliate program has such features.

    If you are promoting affiliate products of A2 Hosting or are planning to join its affiliate program then you can use its AffLinkProtector option to cloak your affiliate link.

    After login to A2 Hosting, under Advanced Ad Tools select AffLinkProtector.

    Now, enter the affiliate URL you want to protect under URL to protect / cloak and select HTML under Redirection type. Now select Generate.

    On selecting Generate, a web page will download. Save this web page to your computer.

    Now upload it to your own website.

    Now, instead of using your normal affiliate code, you can reference your uploaded affiliate web page, and no one can strip off your affiliate ID.

    See the image below.



    If you have not yet joined A2 Hosting affiliate program, join by visiting this link. Join A2 Hosting affiliate program and earn up to $125 per sale.

    Frequently Asked Questions

    Q1. What is affiliate link cloaking?

    Answer. It is the process of disguising an affiliate link to make it appear short, more user-friendly, brandable, and aesthetically pleasing. This is often done to boost click-through rates and prevent link theft.

    2. Why should I cloak affiliate links?

    Answer. Cloaking affiliate links can make them appear more trustworthy and clickable. It also helps improve the user experience by making the links appear more natural within the content.

    3. Is it necessary to cloak affiliate links in WordPress?

    Answer. While it's not mandatory, cloaking affiliate links can enhance the appearance and credibility of the links on your WordPress site, potentially leading to higher conversion rates.

    Q4. How can I cloak affiliate links in a WordPress site without a plugin?

    Answer. You can cloak affiliate links in WordPress by combining custom redirects and HTML coding, and you can utilize your site's .htaccess file to manage redirection.

    Q5. What are the potential benefits of cloaking affiliate links without a plugin?

    Answer. Cloaking affiliate links without a plugin can reduce the reliance on additional software, improve site speed, and reduce the risk of plugin-related conflicts. 

    Q6. Are there any risks or downsides to cloaking affiliate links? 

    Answer. While it's generally safe to cloak affiliate links without a plugin, ensuring the redirection process is properly managed is important to avoid broken links or potential SEO issues. Also, you should fully back up your website before implementing this method to recover from accidental mistakes.

    Q7. Are there any legal considerations when cloaking affiliate links?

    Answer. In affiliate marketing, it's important to comply with FTC guidelines and disclose affiliate relationships, regardless of whether links are cloaked or not.

    Wrapping Up

    Cloaking your affiliate links contributes to a more professional and polished brand image.

    Instead of displaying a string of numbers and symbols, cloaked links can incorporate your brand name or relevant keywords, reinforcing your brand identity and credibility.

    I hope you found this tutorial on how to cloak affiliate links without plugin in WordPress helpful. If you've liked it, please share it with your friends on social media.

    For more related blog articles and tutorials, please check out the below mentioned resources.

    Photo of author

    Deepak Choudhary

    Deepak Choudhary is the founder of He is a Blogger and an Affiliate Marketing Expert. He publishes useful articles for newbie bloggers related to the following topics - Affiliate Marketing, Email Marketing, Software Reviews, Software Tutorials, Blogging, WordPress, SEO, Passive Income, and more.

    2 thoughts on “How to Cloak Affiliate Links Without Plugin in WordPress?”

    Comments are closed.