Granting access with htaccess from specific referrers

MantridMantrid Lockpick Join Date: 2003-12-07 Member: 24109Members
I don't think the title is a very good description, but I'm wondering if its possible to make an .htaccess file that only grants access from a specific referrer.

That is, if you go to type in "site.com/folder" into your address bar, it won't let you go there, but if you click on a link from a specific page, it'll let you in.

Comments

  • KungFuDiscoMonkeyKungFuDiscoMonkey Creator of ns_altair 日本福岡県 Join Date: 2003-03-15 Member: 14555Members, NS1 Playtester, Reinforced - Onos
    edited June 2007
    I think you can do something similar with mod_rewrite but I don't recall the specifics.

    Try looking through these examples.
    <a href="http://stephenjungels.com/jungels.net/articles/mod-rewrite-recipes.html" target="_blank">http://stephenjungels.com/jungels.net/arti...te-recipes.html</a>
  • WyzcrakWyzcrak Pot Pie Aficionado Join Date: 2002-12-04 Member: 10447Forum Moderators, Constellation, NS2 Playtester, Squad Five Blue
    .htaccess (Apache/1.3.37 -- the egotistical version? <img src="style_emoticons/<#EMO_DIR#>/smile-fix.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile-fix.gif" />):
    <!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->RewriteEngine on
    RewriteCond %{HTTP_REFERER} !^http://(www\.)?specificsite.com/.*specificpage.html.*$ [NC]
    RewriteRule \.(gif|exe|filetypesyouwanttoprotect|zip|png)$ - [NC,F,L]<!--c2--></div><!--ec2-->
    You're "in" if you came from the "specific" referrer. 403 error if not.

    If that doesn't give you want you need, I won't be much help. I offer the above only because I've been using it for years to accomplish the very same thing you described.
Sign In or Register to comment.