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....
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
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! |
|
|||
|
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. |
|
|||
|
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. |
|
|||
|
"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 | |
|
|