htaccess - redirect to home page if user comes in others parts of a web site?

This is a discussion on htaccess - redirect to home page if user comes in others parts of a web site? within the Linux Web Servers forums, part of the Web Server and Related Forums category; Using Apache 1.3 and .htaccess, I want to know how to redirect users to the home page (www.domain....


Go Back   Usenet Forums > Web Server and Related Forums > Linux Web Servers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-15-2005
eastcoastguyz
 
Posts: n/a
Default htaccess - redirect to home page if user comes in others parts of a web site?

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!

  #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.
  #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.


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

"eastcoastguyz" <eastcoastguyz@hotmail.com> writes:
> 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!


That could be done (although, strictly speaking, someone could forge
the cookie as easily as they could forge the referrer header).

However, I'm not sure why you want to do this in the first place. It
will make a complete mess of user bookmarks, search engine hits,
people linking to you, etc - all the things that web users are used to
working - and not really gain anything. Possibly your site is an
exception to that due to special circumstances - if so I'd be
interested to know what they are.

--
Chris
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:54 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0