Tuesday, August 7, 2007

Deep Linking How to avoid

A deep link is a direct link to a web site's resource without accessing the main page of the site. For example your site is http://www.abc.com and your contact page is at http://www.abc.com/contactus/contact.html. If a user types the 2nd link without going though the main page, he is called as The Deep Linker.

It becomes a problem for many of the sites which display ads on their first page(the index page). The HTTP protocol doesn't bother if the user is asking for a resource via a deep link or via a normal link. After all, the request which goes to the server is something like this :

GET /contactus/contact.html


for both cases 1. When you access it through a deep link or 2. When you access it normally via first page's link.

So, how to avoid people from linking deep?
Here's a small trick:

1. Check for a cookie at each deep link. If it doesn't exist, redirect to index page.
2. On the index page insert a cookie which gets killed when the browser is closed.


Anyone knowing a non cookie based solution to this problem do post it in the comments

1 comment:

Naveen said...

It can be easily and efficiently achieved on Apache Web Servers by using mod_rewrite. Its the swiss knife of web server admins and developers alike. Another cool resource is http://www.modrewrite.com/