View Single Post

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

Thanks very much for your kind and helpful reply.

Would it make more sense then, to take the approach of setting a cookie
for a user on www.domain.com/homepage and if a user visits other web
pages within that path without the cookie set, they would be redirected
to the /homepage? Of course, the cookie would have a reasonable amount
of time to last, say 24 hours? Thanks!

David Efflandt wrote:
> 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.