Forum Moderators: phranque
mysite.com/index.html (allowed)
mysite.com/a.html (allowed only if come from index.html, otherwise denied)
mysite.com/b.html (allowed only if come from index.html, otherwise denied)
etc
For all denied requests, it should be redirected to the homepage
Is it possible?
I tried this:
Order deny,allow
deny from All
allow from mysite.com
<FilesMatch "(index)\.html$">
allow from All
</FilesMatch>
But it doesn't redirect and it doesn't work :(
You'll find HTTP Referer-based solutions on the Web. But the problem is that the HTTP Referer header is utterly unreliable: It may not be present at all (for example if the URL is typed-in or if the request is from a caching proxy such as those used by AOL and EarthLink), or it may be faked -- and that's easy to do. Therefore, Referer-based access controls are not reliable, and g1smd has recommended the best solution.
Jim
ErrorDocument /403-error.html
#
Options +FollowSymLinks -MultiViews
RewriteEngine on
#
RewriteCond $1 !^(index\.html)?$
RewriteCond $1 !^403-error\.html$
RewriteCond %{HTTP_REFERER} !^(https?;//(www\.)?example\.com.*)?$ [NC]
RewriteRule ^(.*)$ - [F]
This will work to block off-site-referred visitors about 60% of the time. The rest of the time, the referrer will be legitimately blank or spoofed.
Jim