Web目录结构问题

发布于 2024-09-12 02:14:54 字数 203 浏览 4 评论 0原文

这是我的目录结构:

-st.救护车
---public_html
---资源

我的文档根目录是 public_html。我在 resources 中有一个脚本,需要安全地执行(这意味着:普通用户不应该能够执行它)。我该怎么做?

This is my directory structure:

-st.ambulance
---public_html
---resources

My document root is public_html. I have a script in resources that I need to execute securely (meaning: normal users shouldn't be able to execute it). How would I do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

策马西风 2024-09-19 02:14:54

如果普通用户无法在浏览器中访问它,他们将无法执行它。如果它不在您的文档根目录中,他们应该无法访问它。因此,它已经是安全的,除非文档根目录中的脚本之一包含它,或者您的网站被黑客攻击。

至于您自己执行脚本,请了解它是否应该从命令行运行还是作为网页运行。如果它可以在命令行运行,只需 ssh 并运行它。如果它需要作为网页运行,请让您的 Web 服务器将资源目录提供给管理(子)域,并通过 https 进行保护,并使用基本 http 身份验证等密码保护它。

Normal users already won't be able to execute it if they can't get to it in their browser. If it's not in your document root, they shouldn't be able to get to it. So, it's already safe, unless one of the scripts in your document root is including it, or your site gets hacked.

As far as executing the script yourself, find out whether it should be run from the command line or as a web page. If it can run at the command line, just ssh in and run it. If it needs to be run as a web page, have your web server serve the resources directory to an admin (sub)domain, secured by https, and password protect it with something like basic http authentication.

无声静候 2024-09-19 02:14:54

剧本是什么?我想这并不重要,但是你可以做的是使用:

require_once("/../resources/script.php);

我应该补充一点,你当然需要适当地设置你的路径。

What is the script? I guess that doesn't matter so much anyway, but what you can do is use:

require_once("/../resources/script.php);

I should add that you of course need to set up your path appropriately.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文