如何防止通过输入url下载文件设置xml文件但允许php查看
我在服务器上有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有两种方法:
.htaccess
中(但它不能包含应可访问的文件)。
Two ways:
.htaccess
in the folder that contains the XML file (but it cannot contain files that should be accessible).
您可以使用 .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.