保护服务器上的 xml 文件 [英] protect an xml file on server

查看:48
本文介绍了保护服务器上的 xml 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里阅读了很多关于保护 apache 服务器上的文件的答案,有些人告诉 htaccess 仅用于拒绝用户访问文件.对我来说不是..

I read here lot of answers about protecting a file on apache server, some told htaccess is only for deny user access for files. For me not..

使用以下几行我无法访问 xml,但我的 php 脚本也无法访问!

Using the following lines I cant reach the xml, BUT my php script also can't!

<Files sample.xml>
  Order allow,deny
  Deny from all
</Files>

那么如何保护文件不被用户访问,以便我的 php 脚本可以访问它.该文件位于根目录中.

So how to protect a file from users, so that my php script could access it. The file is in the root dir.

推荐答案

如果你在 linux 服务器上,有一个 shell 访问它,你将你的文件权限更改为

If you are on a linux server, have a shell access to it, you change your file permissions to

chmod 0700 yourxmlfile.xml  # this will make it readable/writable/executable only by the creator of the file.

或在您的 .htaccess 文件中,您可以这样做:

or in your .htaccess file, you can do this:

RewriteEngine on
RewriteRule ^yourfile.xml$ 404.html

其中您的 404.html 可能是未找到页面或任何垃圾页面,这些页面将显示为无效 url.

where your 404.html could be either a page not found page or any garbage page, which will display as invalid url.

这篇关于保护服务器上的 xml 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆