开发者

How can I protect a binary file for being downloaded from a web folder?

开发者 https://www.devze.com 2023-04-03 17:30 出处:网络
I am working on a CMS template generator. The users will download th开发者_JAVA技巧e generated template and they will use it on their web server. The template contains a binary file with all important

I am working on a CMS template generator. The users will download th开发者_JAVA技巧e generated template and they will use it on their web server. The template contains a binary file with all important data needed if a user wants to restore the template in the template generator for further changes.

If somebody can download this file, basically, can stole the template. How can I protect this file for being downloaded?

Var. 1: .htaccess

How safe is to use .htaccess? I'm thinking that sometimes, when copying the files it my be lost (being a hidden file on UNIX like platforms) or it may not work on some servers (other than Apache).

Var. 2: .php extension

I was thinking to use .php extension, forcing the web server to parse the content (if somebody tries to access the file directly). Could this be a reliable solution?

Do you know another way?


The safest way is to keep the file somewhere outside the web server's content directory. That way, your code can still refer to it, but the web server itself ignores it completely.


You can protect file using .htaccess or other way is you can upload binary files to bin folder on your web server which is not accessible to end users.

.htaccess code

<FilesMatch .bin>
  Order allow,deny
  Deny from all
  Satisfy All
</FilesMatch>


var 2: no it really isn't. If you put this into php file

hello world

it will output

hello world

PHP is parsed only in tags

0

精彩评论

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

关注公众号