More Info »
Why to hide affiliate links
Purpose of link redirection and masking is to hide affiliate links from search engines, from your competitors (yes you can), and to track clicks on links.
PHP redirection examples
A few redirection examples are chosen, edited, tested, and added to this page. Along with PHP code examples, two more options are added. robots.txt could be used to block search engine spiders access to your redirection script, and .htaccess directives to make your links (url) looking more natural, and to hide scripts from scanners (bad bots). This simple (universal) htaccess mod_rewrite example can be used also for search engine friendly links (/examplepage instead of /?page=examplepage).
Important: Common error with this kind of PHP scripts, due to function used,
is the warning message : "Cannot modify header information"
Hide redirection script from search engines
To use advantage of .htaccess (friendly links), and to avoid that search engine spiders are following affiliate links, we will make folder "redirect", and add a simple directive to robots.txt:
robots.txt is in your root folder, if you don't see it, make it using text editor, add this code above, and upload to server.
Without this in robots.txt, search engine spiders will follow your affiliate link and boost number of clicks.
You will see lower conversion and blame redirection script.
Simple PHP redirection
Save in /redirect/product1.php and call it as yourdomain.com/redirect/product1.php
htacces rewrite example to hide script
To hide php extension , you can use this htaccess example.
Use url yourdomain.com/redirect/product1 or yourdomain.com/redirect/product1/ .
Still simple PHP redirection
Difference between this, and above redirection method, is in quantity. While in above method, you need to make separate file for every affiliate link, here you need the only one file/script.
Save in redirect/test.php , call it as redirect/test.php?id=product1
Make link friendy and hide script using htaccess
Paste code and save as htaccess.txt . Upload htaccess.txt to /redirect/ folder. Rename htaccess.txt to .htaccess.
PHP redirection with flat file database
For storing a few hundred, or more, affiliate links, flat text database (pipe, comma, or any kind of delimiters) could be used,
for those who don't need or don't have access to MySQL base.