Affiliate Marketing is a major source of income for High Traffic WordPress Blogs/Websites. Users clicks on Affiliate Links, then buys products/services and in turn the Site Webmaster gets paid a certain amount of commission by the Company offering Products/Services.
Affiliate Links can be long and ugly. In this Post we will learn How to Hide/Mask Affiliate Links within your own Blog/Website URL using a very simple PHP Code and by .htaccess File!
Suppose you have a Blog/Website Address: http://www.xyz.net and you want to hide following Affiliate Link in your Blog/Website:
Now you want to mask the above affiliate link with a Link (URL) which looks like a part of your Blog’s/Website’s Address:
http://www.xyz.net/products.php or http://www.xyz.net/products
By using PHP Code
All you need is to make use of following PHP Code with the desired affiliate link in it:
<?php header(“location: <Your Affiliate Link Here>“); ?>
Copy the above Code >> Open Notepad >> Paste the above code and Insert the desired affiliate link in it >> Save the file with .php as it’s extension E.g. products.php >> Now Upload this .php File in the Root Directory of your Website using FTP
By using .htaccess File
You can also hide/mask the Affiliate Links using .htaccess file. All you need is to add following lines in your Website’s .htaccess file:
Redirect 301 /products http://products.com/affiliate/1258787455
Above .htaccess Example Code follows the following format:
Redirect 301 /<Term after your Website/Blog URL> http://<Your Affiliate Link Here>
If you want to use PHP Code, than I will personally suggest you to:
- Use target=”_blank”, so that all your Affiliate Links open in New Window
- Use rel=”nofollow”, so that Search Engine Spiders don’t follow/crawl these Redirected Affiliate Links.
Now using above, everytime someone clicks on http://www.xyz.net/products.php or http://www.xyz.net/products, he/she will be redirected to the Website contained in the Affiliate Link.
Hope this Helps lots of Webmasters who want to mask Affiliate Links in their Website/Blog.