Hotlinking to Html pages

Discussion in 'HTML' started by snorkerz@gmail.com, Feb 17, 2006.

  1. Guest

    I'd like customers to only link to my pages from within the website, ie
    not from links or with direct urls. The only one to allow access from
    outside should be the home page.

    I am not sure if .htaccess or javascript is the way to go - could
    anyone offer a suggestion / solution?

    Thanks

    Benji the dog
    , Feb 17, 2006
    #1
    1. Advertising

  2. Dylan Parry Guest

    Pondering the eternal question of "Hobnobs or Rich Tea?",
    finally proclaimed:

    > I'd like customers to only link to my pages from within the website, ie
    > not from links or with direct urls. The only one to allow access from
    > outside should be the home page.


    You can do this with .htaccess, but it isn't very reliable. The main
    problem that you will come across is that some user agents won't send a
    referrer when requesting a page, so they will *always* be redirected to
    your homepage.

    To be honest, I can't see /why/ you are trying to do this? Could you
    explain your rationale so that we could perhaps suggest something
    better?

    --
    Dylan Parry
    http://webpageworkshop.co.uk -- FREE Web tutorials and references
    Dylan Parry, Feb 17, 2006
    #2
    1. Advertising

  3. Guest

    No, I've no idea why either....

    I have offered to build some websites for people so that I can expand
    my knowledge of HTML etc, and this is one of the ones I've put
    together.

    I have seen a javascript which will redirect depending on referrer -
    just not sure if I could use it to refer all enquiries to the home page
    without including every single page on the site in the script? (also, I
    think .htaccess will be tidier). So far as reliability is concerned -
    I'm not too worried, as the site neither holds 'confidential' stuff and
    nor will it generate huge traffic.

    The script is:

    <script language="javascript">
    //by www.a1javascripts.com/
    <!--
    var name = (""+ document.referrer +"" )
    if (name ==
    "http://www.a1javascripts.com/redirection_scripts/index.html") {
    url=(""+ document.referrer +"");
    }
    else if (name ==
    "http://a1javascripts.com/redirection_scripts/index.html") {
    url=(""+ document.referrer +"");
    }
    else if (name == "http://www.a1javascripts.com/redirection_scripts/") {
    url=(""+ document.referrer +"");
    }
    else if (name == "http://a1javascripts.com/redirection_scripts/") {
    url=(""+ document.referrer +"");
    }
    else {

    url=("http://www.a1javascripts.com/");
    }
    document.write('<A HREF="' + url + '">This Link</A>');
    //-->
    </script>
    , Feb 17, 2006
    #3
  4. Andy Dingley Guest

    wrote:
    > I'd like customers to only link to my pages from within the website, ie
    > not from links or with direct urls. The only one to allow access from
    > outside should be the home page.


    Your first sentence is almost meaningless. I assume that what you
    really want is

    "Any links from the outside world to my site should be redirected to
    the homepage"

    This is crazy, but fairly possible. It's your site after all.

    > I am not sure if .htaccess or javascript is the way to go - could
    > anyone offer a suggestion / solution?


    ..htaccess is definitely the way to go. JavaScript is a bad idea in
    several ways and it doesn't solve the oneproblem .htaccess suffers
    from.

    There are five cases you need to deal with, all based on testing the
    HTTP Referer (search for a .htaccess tutorial on the details):

    - A referrer from your own site: Do nothing, just let the page be
    served.

    - A referrer from another site. Redirect to your homepage.

    - Any request for your homepage, with any referrer. DO NOT redirect,
    otherwise you risk redirection loops.

    Now the tricky stuff!

    - A blank referrer, because it's a direct access or a bookmark, not a
    link. You might think you should redirect here.

    - A blank referrer, because the user agent doesn't support them. Do
    you redirect (locking such users permanently into a single page of your
    site) or do you not redirect (allowing referer-less agents to link
    wherever they wish).

    The trouble is that you can't tell the last two cases apart, which
    means that taking the second approach to case 5 also turns off case 4.
    This means that you either have to make the site unusable for
    referer-less agents, or you forbid linking from outside but still
    permit bookmarking.

    Quite honestly the whole idea is a bad one. Locking out linking is bad
    enough, but locking out bookmarks is even worse.


    Why do dezyners still think that offending users is ever a good idea?
    Andy Dingley, Feb 17, 2006
    #4
  5. confused Guest

    Thanks for that Andy.

    No, I can't see the point either, though I've emailed the 'customer' to
    find out.

    I have some very basic .htaccess knowledge so I'll be looking for the
    tutorial you suggested and reading it in conjunction with your
    comments.

    In the mean time...

    anyone got a suitable bit of .htaccess I could pinch? :)
    confused, Feb 17, 2006
    #5
  6. Jukka K. Korpela, Feb 17, 2006
    #6
  7. confused wrote:
    > Thanks for that Andy.
    >
    > No, I can't see the point either, though I've emailed the 'customer' to
    > find out.
    >


    How will your customer like search engines crawlers to be redirected
    away to the home page? People searching for info on his site might never
    find it on google.

    Nick


    --
    Nick Theodorakis

    contact form:
    http://theodorakis.net/contact.html
    Nick Theodorakis, Feb 17, 2006
    #7
  8. Arne Guest

    Arne, Feb 17, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Sandi
    Replies:
    6
    Views:
    516
    Sandi
    Jul 26, 2003
  2. Tigger
    Replies:
    3
    Views:
    489
    kayodeok
    Jan 26, 2004
  3. Dark Angel

    .htaccess & Hotlinking

    Dark Angel, May 1, 2004, in forum: HTML
    Replies:
    2
    Views:
    441
    Dark Angel
    May 2, 2004
  4. Dark Angel

    Hotlinking problem solved

    Dark Angel, May 4, 2004, in forum: HTML
    Replies:
    6
    Views:
    381
    Dark Angel
    May 4, 2004
  5. gcc

    Image Hotlinking

    gcc, Jun 10, 2005, in forum: HTML
    Replies:
    3
    Views:
    457
    Roy Schestowitz
    Jun 10, 2005
Loading...

Share This Page