How to cloak affiliate links in WordPress without plugins


cloak affiliate links in WordPress

How to cloak affiliate links in WordPress without plugins

In this tutorial, we are going see about cloak affiliate links in WordPress without plugins.recently one of our blog reader ask me is there any other way to cloak affiliate link in WordPress without using any plugins.yes possible we can use the PHP Header redirection Method and Array Function’s help to adding Multiple Affiliate URL’s so you no need to create multiple pages for cloak your Affiliate URL

Advantages of cloaking the Affiliate URLs

  • create professional Looking Custom Affiliate redirection link.

Normal Affiliate link – http://yourwebsiteblog.com/aff?id123

Cloaking Affiliate link – http://yourwebsiteblog.com/go/product

  • Help to Increase your CTR
  • it will protect you from a penalty

Supported Platforms

All PHP Supported web server’s


Here is the Crucial method to cloak the affiliate link without plugins

  • First login to your Cpanel/Cloud user’s login from FTP/SFTP
  • Now open File manager in Cpanel (Cloud user’s open app root folder)
  • Now Create a Folder go (Mostly used Affiliate link Prefix)
  • Now create a new File named as index.php
  • Copy the Below code and paste it into Index.php file
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>OOps No Link Found</title>

<!-- Count down redirect using CSS -->
<style>
awt-rd {
padding: 0 8px;
line-height: 1.5;
font-size: 14px !important;
padding: 5px 5px 3px;
background-color: #f7f7f9;
font-family: Consolas, Monaco, Lucida Console, monospace;
color: #336cac;
border: 1px solid #e1e1e8;
}
awt-rd { background-color: #f7f7f9;
border: 1px solid #e1e1e8;
color: #336cac;
font-size: 17px;
}
awt-rd:before {
color: #333;
}
</style>

</head>
<body>


<!-- Modify this according to your requirement -->
<br><div style="text-align:center;"><h3><awt-rd>you Redirecting to our Homepage after <span id="countdown">6</span> seconds</awt-rd></h3></div><br><br>

<!--Count down redirect JavaScript -->
<script type="text/javascript">

// Total seconds to wait
var seconds = 6;

function countdown() {
seconds = seconds - 1;
if (seconds < 0) {
// Chnage your redirection link here
window.location = "Your Homepage URL";
} else {
// Update remaining seconds
document.getElementById("countdown").innerHTML = seconds;
// Count down using javascript
window.setTimeout("countdown()", 1000);
}
}

// Run countdown function
countdown();

</script>


</body>
</html>
  • Replace Your Homepage URL with your Blog/website URL.if user open the link website.com/go it will redirect to your website/blog Homepage.
  • Now create a new File Named as afflinks.php this is very important file we are going to add our all affiliate link this file only,
  • Now copy the Below PHP code and paste it into afflinks.php file
<?php
$links=array
(
'digitalocean'=>'https://digitalcoean.com', // Your Affiliate is http://example.com/go/digitalocean
'product2'=>'Product Affiliate link',
'product3'=>'Product Affiliate link'
// etc... last line without comma
);
if (array_key_exists($_GET[id],$links))
{
header("HTTP/1.1 301 Moved Permanently");
header("Location:" . $links[$_GET[id]]);
}
else {echo "OOps Link Not Found";}
exit(); ?>
  • this script having PHP Array Function’s so we can add Multiple Affiliate URL’s on the single page

Learn More PHP Array Functions – refer

Example usage

'digitalocean'=>'https://digitalcoean.com/id111', // Your Affiliate is http://example.com/go/digitalocean
  • Final step Create a .htaccess file and copy the below rewrite rules code and paste it into .htaccess file
RewriteEngine On
RewriteRule ^([a-zA-Z0-9_-]+)$ afflinks.php?id=$1
RewriteRule ^([a-zA-Z0-9_-]+)/$ afflinks.php?id=$1 [L]
  • It will Generate a Userfriendly Affiliate cloaking URL (http://example.com/go/myaff)
  • That’s all Successfully we installed the PHP Affiliate Cloaking Plugin for website/blogs.

SEO settings

Add Disallow: /go/ on your robots.txt file or add like this

<a href="http://www.mywebsite.com.com/go/product" rel= "nofollow" target= "_blank">text</a>

FAQ

1 – Possible to change the Link prefix?

yes, you can change the Link Prefix the default one is go just Change the folder name Fox example I want to use a word love as my Link Prefix just rename the folder name to love.

2 – How to add the affiliate links?

Just open the file afflinks.php file and add your Affiliate links.

If you Have any doubt in cloak affiliate links in WordPress without plugins.kindly Please Feel free to comment here I will help you.

 



Was this article helpful?
Thanks!

Your feedback helps us improve Allwebtuts.com