View Single Post

  #2 (permalink)  
Old 01-15-2005
David Efflandt
 
Posts: n/a
Default Re: htaccess - redirect to home page if user comes in others parts of a web site?

On 14 Jan 2005 22:37:33 -0800, eastcoastguyz <eastcoastguyz@hotmail.com> wrote:
> Using Apache 1.3 and .htaccess, I want to know how to redirect users to
> the home page (www.domain.com/homepage) if they came in linked from
> another domain to www.domain.com/someotherpage
>
> I was looking at the documentation and it looks like using
> HTTP_REFERER would contain the information if the user wasn't coming in
> from a link from www.domain.com.
> Can anyone provide a sample script to do this? Thanks!


HTTP_REFERER is an _optional_ browser supplied variable, which depending
upon browser settings, source of link, or whether going through a proxy,
may not appear at all (especially if from a bookmark/favorites, e-mail,
news post, etc.). It is also easily forged, for example a script making
an HTTP request can set it, and other browser related variables, to
anything valid, whether true or not.

So about the only time you can rely on HTTP_REFERER for anything is "if it
exists AND is NOT what you want it to be". If HTTP_REFERER does not
exist, has no value, or is correct, you should accept it. Any method you
use to redirect should take that into account.