开发者

htaccess set specific file to download only

I'm working on developing a javascript framework and I don't want anyone to be able to link to the "nightly build" .js file directly on the server.

Based on my research from google, here's what I have in my htaccess:

<FilesMatch /development/flanvas/flanvas.js>
 ForceType applicaton/octet-stream
</FilesMatch>

And I've also tried putting a .htaccess file in /development/fl开发者_Go百科anvas/ and adding:

AddType applicaton/octet-stream.js

Neither have worked so far :(

*edit

I suppose if a user really wanted to snag this, they could curl/ajax it. Is it advised to have the .htaccess check the HTTP_REFERER instead? This could potentially get two birds with one line..


Is the root of your server really the DocumentRoot for the website?

i.e. is /development/flanvas/flanvas.js the absolute path to the JS file on your machine?

I would try

<FilesMatch ^(.*)flanvas\.js$>
   ForceType applicaton/octet-stream
</FilesMatch>

or

<FilesMatch /path/to/documentroot/development/flanvas/flanvas.js>
   ForceType applicaton/octet-stream
</FilesMatch>

Hope this helps


This is the person that asked the question. Apparently I have no idea what account I posted this question under, but once I figure it out I'll come back and checkmark your question is it 100% worked.

Ended up using:

# Force download for flanvas.js
<FilesMatch ^(.*)flanvas\.js$>
 ForceType applicaton/octet-stream
</FilesMatch>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜