Hotlinking to Html pages

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
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?


Benji the dog

Re: Hotlinking to Html pages

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

Quoted text here. Click to load it

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

Dylan Parry -- FREE Web tutorials and references

Re: Hotlinking to Html pages wrote:

Quoted text here. Click to load it

Yes, we can see that. Your customer or "customer", whichever it is,
most probably lacks a clue, too.

Before digging any deeper and wasting time and effort in creating
problems, check at least Jakob Nielsen's nice little "Deep Linking is
Good Linking",

Yucca, /
Pages about Web authoring:

Re: Hotlinking to Html pages wrote:
Quoted text here. Click to load it

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.

Quoted text here. Click to load it

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

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

 - 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?

Re: Hotlinking to Html pages

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

In the mean time...

anyone got a suitable bit of .htaccess I could pinch? :-)

Re: Hotlinking to Html pages

confused wrote:
Quoted text here. Click to load it

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 Theodorakis
contact form:

Re: Hotlinking to Html pages

Once upon a time *confused* wrote:
Quoted text here. Click to load it

Thank's for what?

Quoted text here. Click to load it

Hard for others to, to see a point when I don't see what you are
replying to.

Please, read the tutorials about replying and quoting on Usenet:

* How to quote:
* From Google: /


Now ignoring posters who don't quote

Site Timeline