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

查看:181
本文介绍了保护服务器上的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可以是一个找不到页或任何的垃圾页面,该页面将显示为无效链接。

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天全站免登陆