Forum Moderators: DixonJones

Message Too Old, No Replies

Tracking outgoing links with redirect

Using Apache .httacces redirect to track outgoing links

         

eflouret

5:16 pm on Jan 6, 2002 (gmt 0)

10+ Year Member



I have a number of outgoing links that I would like to track (no more than 10 or 20).

I don't want to use any cgi or tracking software.

Is it ok to use Apache .httaccess redirect to place links like "http://www.mysite.com/othersite.html"
and then redirecting it to the proper site?

How about using PERMANENT REDIRECT instead of the plain REDIRECT command?

Would it have a negative, positive or neutral impact on Spiders following those links?

This way I can place simple urls and then tracking them with my log file analysis software which are much more customizable than link tracking software.

Any suggestions or comments?

Thanks,

Enrique Flouret

Brett_Tabke

11:18 am on Jan 9, 2002 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



When I first read this, I thought it was a brillant idea. I still do. Most spiders will follow that just fine. I'd be interested to hear your results after a few months.

Marcia

11:33 am on Jan 9, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm not following, I got lost someplace. What will it look like in htaccess?

eflouret

10:12 pm on Jan 18, 2002 (gmt 0)

10+ Year Member



Thanks Brett, it's an honor!

I didn't reply to this post because I didn't received mails notifications.

I didn't try this yet, but since I have not received any negative experience I think it might be possible.

The reason for doing this is because I didn't find any decent tracking script. There must be one for sure, but it is difficult to download and check everyone of them.

Redirecting links through .httaccess is more straightforward. You simply open the .httacess file with notepad or similar and start to copy and paste the links one below the other.

Filling cgi trackers forms (in my own experience) is a long and painful work and has to be done online. Going back and forth with your browser really slows down the process.

With .httacess redirect links will look like:
www.yoursite.com/whatever (a godsend for text newsletters)
instead of
www.yoursite.com/cgi-bin/track.cgi?whatever

It should be faster to redirect urls through .httaccess than with a cgi.

Also, you can track your urls with a Server Log Analyzer and can get much more info than with cgi trackers.

The .httaccess would look like this

Redirect permanent /whateverfile [othersite.com...]

Redirect permanent /whateverfile2 [othersite.com...]

I don't think that there would be any problem with search engines, but I wanted to know if somebody had some input on that.

I will try this and then tell you what were the results.

thanks again!

AC_Design

7:19 pm on Jan 21, 2002 (gmt 0)

10+ Year Member



I've been considering this myself. I'm a little concerned about the 301 error code that is sent when using a permanent redirect... but I dunno - I'm curious if it is a problem or not.

I'll look forward to hearing your results.
Peace

eflouret

9:26 pm on Jan 21, 2002 (gmt 0)

10+ Year Member



I've set up my links via .htaccess and they work faster than the ones through a cgi. Also, it took me just seconds to do that (just copy and paste in notepad).

AC_Design, you are making me doubt if what I did will not only hurt my rankings, but if my domain will be dropped from search engines.

It seems that won't happen, but who knows...

As far as I know if I redirect [mydomain.com...] to [othersite.com...] search engines will drop the first url and index the second one, so no harm can be done to my domain.

Googleguy, Brett? Any input on this?

Thanks

amoore

11:20 pm on Jan 21, 2002 (gmt 0)

10+ Year Member



If you have mod_perl in your apache (and how could you not?) here's what I would do for a pretty cool trick.

make a module Redirect.pm like this:

package Redirect;

sub handler {
my $r = shift;
$r->method('GET');
$r->headers_in->unset('Content-length');
$r->content_type('text/html');
$r->header_out('Location' => $r->path_info() );
return 302;
}
1;

Then put it somewhere where your apache perl instance can find it.

Then make a directory like "/redirect" in your webroot with a .htaccess like this:

SetHandler perl-script
PerlHandler Redirect

Then if you make a link like: [example.com...] the perl module will return a redirect to the url. Faster than a CGI, and pretty easy to maintain.

Then, to find the links people used to leave your site, you can use your standard log analysis tools.

Slick or what?

amoore

12:24 am on Jan 22, 2002 (gmt 0)

10+ Year Member



well, that didn't take long, and I have found (what I believe to be) a better way.
Just put this in your .htaccess in "/redirect"

Redirect /redirect/ http://

then if you make a link like [example.com...]
the browser gets sent there and an appropriate line gets thrown in your access log.

I'm still looking for a way that you don't have to hard-code the "http://" part, probably using RedirectMatch and such, but I just don't get some stuff.

You should note that both this method and the last I outlined strip off the query strings from the URL before sending the client there, so no fair sending them to example.com?foo=bar

Also note that this method doesn't depend on the (inappropriately named) module I mentioned in the last post.

Would this do the trick for you?