大网数据广告活动
网站运营与故障问答

How to protect my files on Heroku

· 52CE 我爱测

My sendemail.php file is located in the root of my website, is there a way to protect it? Also i want to protect or hide my js folder, so noone can see my code with direct link or via the google inspect console. I have tried the …

问题原文

原帖链接 · csandreas1 · CC BY-SA 3.0

My sendemail.php file is located in the root of my website, is there a way to protect it? Also i want to protect or hide my js folder, so noone can see my code with direct link or via the google inspect console. I have tried the following with htaccess, the files don't appear in the console but i can see them with direct link. Here is what i have in the htaccess:

#<Files ~ "\.js$">
 #   order allow,deny
  #  deny from all
#</Files>

For example on a website i inspect with firebug and i can't see the files.

已采纳解答

原帖链接 · MrWhite · CC BY-SA 3.0

#<Files ~ "\.js$">
#   order allow,deny
#  deny from all
#</Files>

Yes, you will get a 403 Forbidden with the above code when trying to access any .js file, regardless of the way you access it, either from a direct link or when linked in your HTML source (unless it is pulled from your browser cache).

And that's the problem, you can't really protect client-side JavaScript files. They need to be downloaded to the client/browser in order to run. Once they are downloaded, they can be viewed.

However, sendmail.php is a different matter. This runs entirely on the server. But it depends on how it is being called whether it can be "protected". For example, if it's being called directly from an HTML form's action attribute then it can't simply be "hidden", as it will be hidden from your HTML form as well. In this case you need to make sure the script is secure, validating all inputs, spam protection, etc.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2017-01-02)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。