如何防止通过输入url下载文件设置xml文件但允许php查看

发布于 2024-10-07 16:00:45 字数 75 浏览 0 评论 0原文

我在服务器上有一个 xml 文件,其中包含数据库服务器的详细信息。我不希望任何人能够通过 url 访问它,但 PHP 应该能够加载该文件

I have an xml file on the server containing details to the database server. I don't want anyone to be able to access it via url but PHP should be able to load the file

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

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

发布评论

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

评论(2

乖不如嘢 2024-10-14 16:00:45

有两种方法:

  • 简单地将所有这些类型的文件移到 webroot 之外,例如 /application 而不是 /public_html/myapplication。您只需要 webroot 内的可访问页面(index.php 等)。
  • 或者,如果不可能/太难,请将其添加到包含 XML 文件的文件夹中的 .htaccess 中(但它不能包含应可访问的文件)

Order Allow,Deny
Deny from All

Two ways:

  • Simple move all those kinds of files outside the webroot, for example /application instead of /public_html/myapplication. You only need accessible pages (index.php etc.) inside the webroot.
  • Or if that's not possible/too hard, add this in .htaccess in the folder that contains the XML file (but it cannot contain files that should be accessible)

.

Order Allow,Deny
Deny from All
不知所踪 2024-10-14 16:00:45

您可以使用 .htaccess 文件: http://httpd.apache.org/docs/ 1.3/howto/htaccess.html
但是,为什么要把它放在 XML 中呢?将其作为变量放入 PHP 中,那么即使他们访问该页面也看不到它。

you could use .htaccess file: http://httpd.apache.org/docs/1.3/howto/htaccess.html
but, why put it in XML? put it in PHP as variables, then even if they visit the page they won't be able to see it.

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