{"id":374,"date":"2007-04-20T07:19:28","date_gmt":"2007-04-20T12:19:28","guid":{"rendered":"http:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links"},"modified":"2009-03-13T10:58:10","modified_gmt":"2009-03-13T14:58:10","slug":"how-to-redirect-affiliate-links","status":"publish","type":"post","link":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links","title":{"rendered":"How To Redirect Affiliate Links"},"content":{"rendered":"

This tutorial will show you how to redirect your affiliate links using a PHP script and a simple edit to your .htaccess file. For some reason users seem to trust links more if the reside on your own server. Using a “link cloaking” technique is an easy way to increase revenue from affiliate offers. <\/p>\n

For this tutorial we will use the website www.scholarshiphunter.info for example. On the left navigation menu you will see an affiliate section.
\nHow To Redirect Affiliate Links<\/a><\/p>\n

If you mouse over you will notice that the link goes to a folder on the site called links.
\n
How To Redirect Affiliate Links<\/a><\/p>\n

Really, the folder \/links doesn\u2019t exists. We modify the .htaccess file to redirect the requests for the url \/links to a script called link.php. So for example:<\/p>\n

http:\/\/www.scholarshiphunter.info\/link\/efinance-loans<\/p>\n

actually redirects you to the real url:<\/p>\n

http:\/\/www.scholarshiphunter.info\/link.php?id=efinance-loans<\/p>\n

It may sound difficult, but it is really very simple. First create the PHP file that will redirect the links to the appropriate affiliate offers. You can do this in notepad if you don\u2019t have an editor of choice, however I will use Dreamweaver because I like the way it colors the code.
\n
How To Redirect Affiliate Links<\/a><\/p>\n

Basically the only things that you need to change are the link variable and the affiliate link. The link variable is the \u201cfolder\u201d that you want the link to be sent to on your server. The affiliate id is the affiliate link provided by your affiliate company. The bottom section of code simply gets the id variable from the browsers and redirects you to the affiliate offer, using a header redirect.<\/p>\n

Here is the exact PHP code used on scholarshiphunter.info:
\n
How To Redirect Affiliate Links<\/a><\/p>\n

Create to file, replacing the variable and the afflaite links with your own, and save it as link.php. Upload this file to the root of your web directory on your server. Just remember that when you edit the file, do not include a comma on the last affiliate link offer.<\/p>\n

How To Redirect Affiliate Links<\/a><\/p>\n

Once you have the link.php file uploaded you could simple link to it. So if my keyword was coolstuff, the link would be http:\/\/www.scholarshiphunter.info\/link.php?id=coolstuff . However, we will redirect the request using .htaccess to make the files appear to be in folders on the server. Log into your server via ftp and edit the .htaccess file. Add the following lines of code:<\/p>\n

RewriteEngine On
\nRewriteRule ^link\/([\/_0-9a-zA-Z-]+)$ link.php?id=$1<\/p>\n

That code simply tells the server to rewrite any url that is calls the folder \/links\/yourvariablehere to the real link.php?id=yourvariblehere. This all happens in the background so the users sees the \/links\/yourvariblehere link.<\/p>\n

It is that simple. Now all you have to do is add the affiliate links to your page. Here is what the links look like on scholarshiphunter.info:<\/p>\n

How To Redirect Affiliate Links<\/a><\/p>\n

It is really that easy, now go make some money!<\/p>\n","protected":false},"excerpt":{"rendered":"

This tutorial will show you how to redirect your affiliate links using a PHP script and a simple edit to your .htaccess file. For some reason users seem to trust links more if the reside on your own server. Using a “link cloaking” technique is an easy way to increase revenue from affiliate offers. <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[24,17],"tags":[],"yoast_head":"\nHow To Redirect Affiliate Links<\/title>\n<meta name=\"description\" content=\"This tutorial will show you how to redirect your affiliate links using a PHP script and a simple edit to your .htaccess file. For some reason users seem to trust links more if the reside on your own server. Using a "link cloaking" technique is an easy way to increase revenue from affiliate offers.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Johnathan Ward\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/teamtutorials.com\/#website\",\"url\":\"https:\/\/teamtutorials.com\/\",\"name\":\"Team Tutorials\",\"description\":\"Learn something new today\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/teamtutorials.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/04\/redirect-affliate-links-tutorial-01.jpg\",\"contentUrl\":\"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/04\/redirect-affliate-links-tutorial-01.jpg\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#webpage\",\"url\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links\",\"name\":\"How To Redirect Affiliate Links\",\"isPartOf\":{\"@id\":\"https:\/\/teamtutorials.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#primaryimage\"},\"datePublished\":\"2007-04-20T12:19:28+00:00\",\"dateModified\":\"2009-03-13T14:58:10+00:00\",\"author\":{\"@id\":\"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9\"},\"description\":\"This tutorial will show you how to redirect your affiliate links using a PHP script and a simple edit to your .htaccess file. For some reason users seem to trust links more if the reside on your own server. Using a \\\"link cloaking\\\" technique is an easy way to increase revenue from affiliate offers.\",\"breadcrumb\":{\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/teamtutorials.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How To Redirect Affiliate Links\"}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9\",\"name\":\"Johnathan Ward\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/teamtutorials.com\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r\",\"caption\":\"Johnathan Ward\"},\"description\":\"Johnathan Ward is an experienced developer and consultant that writes tutorials to help other developers. In his day job, he is an IBM Watson Consultant with several years of experience deploying and customizing Watson Explorer solutions.\",\"sameAs\":[\"http:\/\/johnathanward.com\",\"https:\/\/twitter.com\/spyderman4g63\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How To Redirect Affiliate Links","description":"This tutorial will show you how to redirect your affiliate links using a PHP script and a simple edit to your .htaccess file. For some reason users seem to trust links more if the reside on your own server. Using a \"link cloaking\" technique is an easy way to increase revenue from affiliate offers.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links","twitter_misc":{"Written by":"Johnathan Ward","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebSite","@id":"https:\/\/teamtutorials.com\/#website","url":"https:\/\/teamtutorials.com\/","name":"Team Tutorials","description":"Learn something new today","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/teamtutorials.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"ImageObject","@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#primaryimage","inLanguage":"en-US","url":"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/04\/redirect-affliate-links-tutorial-01.jpg","contentUrl":"http:\/\/teamtutorials.com\/wp-content\/uploads\/2007\/04\/redirect-affliate-links-tutorial-01.jpg"},{"@type":"WebPage","@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#webpage","url":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links","name":"How To Redirect Affiliate Links","isPartOf":{"@id":"https:\/\/teamtutorials.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#primaryimage"},"datePublished":"2007-04-20T12:19:28+00:00","dateModified":"2009-03-13T14:58:10+00:00","author":{"@id":"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9"},"description":"This tutorial will show you how to redirect your affiliate links using a PHP script and a simple edit to your .htaccess file. For some reason users seem to trust links more if the reside on your own server. Using a \"link cloaking\" technique is an easy way to increase revenue from affiliate offers.","breadcrumb":{"@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/teamtutorials.com\/web-development-tutorials\/how-to-redirect-affiliate-links#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/teamtutorials.com\/"},{"@type":"ListItem","position":2,"name":"How To Redirect Affiliate Links"}]},{"@type":"Person","@id":"https:\/\/teamtutorials.com\/#\/schema\/person\/3abea1fc71644afe035403357450b9d9","name":"Johnathan Ward","image":{"@type":"ImageObject","@id":"https:\/\/teamtutorials.com\/#personlogo","inLanguage":"en-US","url":"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/93d667fe5dc6df5c722e0df5eac14d40?s=96&d=mm&r=r","caption":"Johnathan Ward"},"description":"Johnathan Ward is an experienced developer and consultant that writes tutorials to help other developers. In his day job, he is an IBM Watson Consultant with several years of experience deploying and customizing Watson Explorer solutions.","sameAs":["http:\/\/johnathanward.com","https:\/\/twitter.com\/spyderman4g63"]}]}},"_links":{"self":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts\/374"}],"collection":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/comments?post=374"}],"version-history":[{"count":0,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/posts\/374\/revisions"}],"wp:attachment":[{"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/media?parent=374"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/categories?post=374"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/teamtutorials.com\/wp-json\/wp\/v2\/tags?post=374"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}