.htaccess vs php for affiliate link redirects?

Online18Casino

Affiliate Guard Dog Member
Joined
Sep 7, 2009
Messages
596
Reaction score
58
What do you guys use for linking to aff programs? As far as redirects go, .htaccess or a php redirect file? Right now I am linking directly, and:
1. I think this may help my seo a little, by not linking directly out to affiliate programs...?
2. affiliate programs keep changing there links anyway, and this will make it easyer to update them all at once.
 

Vladi

Affiliate Guard Dog Member
Joined
Feb 4, 2008
Messages
772
Reaction score
115
You should use both.

Here is an ideal setup:

1. All your affiliate links are stored in a database (or php file - use whatever you are comfortable with) in one spot, not scattered all over your sites repeatedly on countless different pages.
2. The links presented on your pages could be something like "www.yoursite.com/goto/acasino" instead of the actual affiliate links. The "acasino" part will be unique to each site or affiliate link obviously - you could even just use a number that corresponded to the link record in the database if you want.
3. In .htaccess you internally redirect any requests made to "www.yoursite.com/goto/.*" to a php script that will do the redirection.
4. The php script fetches the correct link from the database based on the "acasino" part of the link. You can even log the click in your own database here for your own records.
5. The php script then redirects the visitor.
6. Don't forget to block the /goto/ links in robots.txt so they don't get followed or indexed.

If that is too tricky to set up yourself, hire someone who can do it. It will save you loads in the long run as the advantages are many. For example when an affiliate program changes their links, you will spend 1 minute updating the link in your database or php file while loads of other people complain in forums like this that it isn't fair and they have hundreds of pages to update. Plus you will no longer be giving affiliate programs free link juice as you will no longer be embedding their affiliate links directly in your pages. And as mentioned beforee, you can do your own logging and even compare against the affiliate program numbers at the end of the month if you want.
 

Online18Casino

Affiliate Guard Dog Member
Joined
Sep 7, 2009
Messages
596
Reaction score
58
Thank you, I have changed some of my more popular links to use .htaccess Redirect 302. Is the main purpose of using the .php with the .htaccess to track your own clicks? Besides logging, does it serve any other purpose to use the .php redirect with the htaccess redirect?

Thank you again for your answer! Good tip with the blocking /goto/ in robots.txt, I did forget that :)
 

Vladi

Affiliate Guard Dog Member
Joined
Feb 4, 2008
Messages
772
Reaction score
115
Besides the logging, you need to use php if you want to fetch your links from a database or have any other complex rules that aren't suitable for .htaccess.

You could hard code a list of affiliate link rules in .htaccess instead I suppose but the php approach is ultimately more flexible and allows you more room to grow in the long run. If you only work with a small number of affiliate links then you may prefer to do it that way.
 

Online18Casino

Affiliate Guard Dog Member
Joined
Sep 7, 2009
Messages
596
Reaction score
58
Okay I understand what you mean now. Last Q i think. Do you use rel=nofollow as well? and if so at what point do you use it? In the link on your main page "www.yoursite.com/goto/acasino" rel="nofollow"

Or do you use it in the php file after the first htaccess redirect?

$path = array(
'acasino' => 'www.affiliateprogram.com/'

Somewhere in there, idk how to place rel=nofollow in the php, maybe a nofollow robots meta tag for the whole php links page? if you can even do that? I can look at php and edit it, but no clue how to write it.

But if you use a nofollow tag, where would be the best area to place it?
 

Vladi

Affiliate Guard Dog Member
Joined
Feb 4, 2008
Messages
772
Reaction score
115
Okay I understand what you mean now. Last Q i think. Do you use rel=nofollow as well? and if so at what point do you use it? In the link on your main page "www.yoursite.com/goto/acasino" rel="nofollow"

We do but its probably redundant because we also block /goto/ in robots.txt. As Google respects robots.txt it won't crawl the links.

We don't actually hard code affiliate links, we call a php function that constructs them so we can easily put the nofollow in there. If you are going to manually replace links all over the place then I would not bother doing it.

You can put a nofollow in a page level meta tag but that affects every outgoing link on the page that has the tag, not the individual links that link to that page. Again, as you have blocked your redirection script in robots.txt it isn't necessary.
 

oolong

New Member
Joined
Apr 29, 2012
Messages
9
Reaction score
0
I have a tiny bit of php experience.
Im having a go at storing the aff links in a php file, trying to avoid mysql database.

I need some tutorials, not sure what that a database like that would be called.

Also would it be open for hijacking if I do it like that? or is it safe?
 

Online18Casino

Affiliate Guard Dog Member
Joined
Sep 7, 2009
Messages
596
Reaction score
58
Try this affiliatebible.com/general-seo/how-to-redirect-affiliate-links.php

That helped me a bit, scroll down to "Using a PHP Jump Script to Redirect Affiliate Links"
 
Top