Forum Moderators: phranque

Message Too Old, No Replies

Masking affiliate links

Does this redirect cover every case?

         

WebWalla

10:31 am on Nov 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have done the following in .htaccess to redirect affiliate links on one of my sites (where example.com in this example is the product site) ...

Redirect 302 /link http://www.example.com

... and in robots.txt I have this ...


User-agent: *
Disallow: /link

The idea is to make all links like this...
mysite.com/link/example.php?param1=a&param2=b&param3=c

... redirect to ...

example.com/example.php?param1=a&param2=b&param3=c

This seems to work perfectly, but I just wanted to check that I am not missing anything, because the parameters and the file example.php may change.

Also, can anybody confirm that this redirect plus the robots.txt file will totally mask these affiliate links from SE's?

Thanks.

[edited by: WebWalla at 10:36 am (utc) on Nov. 20, 2007]

jdMorgan

3:31 pm on Nov 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you Disallow /links, then spiders won't request those URLs, and so they'll never see your redirects. And if you use a 302 redirect as shown, then they will keep the old URLs and index the content using those old URLs.

I'd recommend removing the /links Disallows in robots.txt, and using a 301 redirect.

Jim

WebWalla

4:19 pm on Nov 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In fact that's exactly what I want:

I don't want the spiders to see my redirects because I don't want the SE's to see these affiliate links on mysite.com. I want them to think I am linking to content on my own site, even though the destination pages won't be indexed.

I also want the SE's to maintain the old URL's (mysite.com/link/example.php?param1=a&param2=b&param3=c) and not the new ones on example.com

Thanks.

jdMorgan

5:57 pm on Nov 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The proper way to do that would be to cloak these URLs. But that would be 302-Hijacking.

Jim

WebWalla

6:39 am on Nov 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, these redirects simply didn't feel right, so I've finally decided to do it via a Perl script ...

#!/usr/bin/perl
if ($ENV{'REQUEST_METHOD'} eq "GET") {
$in = $ENV{'QUERY_STRING'};
} else {
$in = <STDIN>;
}
$in =~ s/%(..)/pack("c",hex($1))/ge;
$params=$in;
$url='http://www.example.com/' . $params;
print "Location: $url\n\n";

It will be called in this way ...

mysite.com/cgi-bin/redirect.cgi?dir1/example.php?param1=a&param2=b&param3=C