如何隐藏我的脚本文件夹?
我的网站上有一个专门用于 javascript 文件的目录,我希望隐藏这些 javascript 文件,因此如果我输入该 url,它会显示“禁止”或不允许访问,但我的前端网站文件仍然可以访问它们来执行它们当需要时。有没有办法通过 FTP 客户端来做到这一点?
干杯, 担
I have a directory on my website specifically for javascript files, I want these javascript files to be hidden, so if I type the url to it it says Forbidden or disallows access, but my front-end website files can still access them to execute them when needed. Is there a way to do this through a FTP client?
Cheers,
Dan
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您无法通过 ftp 客户端执行此操作。网络服务器的任务是禁止访问某些文件。
如果您更改权限,网络服务器将无法再访问它们,因此这不是正确的方法。
您必须配置网络服务器以限制访问。如果您使用 Apache,则可以使用
.htaccess
文件。有不同的方法可以做到这一点,许多方法取决于网络服务器的配置方式。最简单的方法是在您的 Scripts 文件夹中放置一个
.htaccess
文件,其中仅包含此 none 行:但是,就像 Peeter 所说,这很有可能会破坏您的网站,因为浏览器必须访问这些文件,因此您无法限制访问。
You can't do this trough a ftp client. It is the task of your webserver to forbid access to certain files.
If you change permission, the webserver won't have access to them anymore, so this is not the way to go.
You must configure your webserver to restrict the access. If you're using Apache, you can use an
.htaccess
file. There's different ways of doing this, many depends on the way the webserver is configured.The easiest is to put an
.htaccess
file in your Scripts folder which contain only this none line :However, like peeter said, there's a good chance this will break your site, since the browser must access theses files, so you can't restrict access.
将 htaccess 文件放入包含
deny from all
的脚本文件夹中,但这也会阻止您的页面访问脚本(尽管如果您首先通过 PHP 引擎传递脚本则不会)Put a htaccess file in your scripts folder containing
deny from all
, but this will stop your pages from accessing the scripts also (though not if you pass them through the PHP engine first)您试图隐藏在客户端执行的 JavaScript 文件。如果客户端(浏览器)无法访问这些文件,则意味着您的 JavaScript 代码不会被执行。
如果我正确理解你的问题,那么你就无法实现你想要实现的目标。
You're trying to hide JavaScript files that are executed on the clients side. If a client(browser) cannot access the files means non of your javascript code is executed.
If I understood your question correctly then you cannot achieve what you're trying to achieve.