I'm planning to add a mod rewrite rule so that a selection of my outgoing links (that I want to track) are specified in the form: /link/http://the.remote.link.com, with the rule designed to remove /link/ and force a 301 redirect to the site (ensuring that the redirect only occurs if the http referer is my site itself, and the outgoing link is one specified in a rewrite map). The purpose of this is so that I can pick up /link/XYZ in my logs.
Are there any considerable downsides of doing this? Is it a worthwhile practice?
Just a comment... You should also allow the rewrite to occur if the referrer is blank. Many people using Norton Internet Security, certain firewalls, corporate proxy servers, etc. will have their HTTP_REFERER field blocked (and may not have a choice about it), and might otherwise perceive your site to be broken.
As a follow up, I have been using this mechanism for a while now, and my observations are: - it works correctly for most UA's. - it fails to work for a number of automated UA's (search engine's) who take the original URL ("/link/http://foo.bar") and remove the double back-slashes ("/link/http:/foo.bar") which gets them a 404. I think that I may be non standards conformant with this approach. I have seen other approaches that do something like "/link/http/foo.bar" which is probably so that they can work around the above breakages.