Open a file w/ htaccess (or advanced hotlinking protection)

Posted on 2006-04-17
Last Modified: 2010-03-04
Basically what I'm trying to do is prevent hotlinking in a fast, but effective, way. My plan was to require certain hotlinkable files to supply a hash when accessed like...
The hash changes, so old hashes eventually stop working.The catch is, I can only use htaccess files, so I can't use RewriteMap, which would make this fairly easy.

I'd make a proxy-like php script, but that's too big of a performance hit. So I'm looking for a way to access the file with the latest hash, or just a script, and check them against an argument ("hash") in the query. Seems simple enough, but I can't find anything.

The server is Apache 1.3, and I don't have access to http.conf, unfortunately.
Question by:Staticreator
    LVL 27

    Expert Comment

    It's impossible to control characters behind '?' without using rewrite rules or LocationMatch or some wrapper script.
    rewrite rules and location are not permitted in .htaccess, so wrapper is the only solution. What is a problem with PHP script performance?


    Author Comment

    ...what? Rewrite rules (mod_rewrite) are allowed in .htaccess files, my problem is that I can't check any rewrite rules against a hash.

    From what I've read, the performance of any PHP wrapper would be much slower. As always, Apache handles sending static files much better than anything I could ever write, and I'd prefer to keep it that way.
    LVL 27

    Accepted Solution

    If you have control over .htaccess, can write php script that will modify your .htaccess

    Author Comment

    Seems so obvious now. Thanks!

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Suggested Solutions

    If you've heard about htaccess and it sounds like it does what you want, but you're not sure how it works... well, you're in the right place. Read on. Some Basics #1. It's a file and its filename is .htaccess (yes, with a dot in the front). #…
    If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now