如何禁止在folderX 中创建新文件?
在 /folderX/
文件夹中,有 4 个 .txt 文件。
目前,php 脚本会根据 url 的 site.org/foo/
创建新文件(如果不存在),如果 foo.txt 不存在,它会更新新文件,然后它将继续创建它。
但我希望: A)如果现有文件已在文件夹中,则允许其更新/重写,但是 B) 如果文件不存在,例如 foo.txt,则不允许它在文件夹 /folderX/ 中创建更多新文件
原因是搜索引擎有时会意外检查 /images/ 或 /icons/ 或 /articles/ 等文件夹,然后创建所有这些文件,然后 PHP 开始处理它们。如果无法创建该文件,那么 PHP 可能不会处理它们,并向奇怪的爬虫程序提供他们应得的错误。
我应该在 FTP 文件夹folderX 中设置哪些属性,以推翻任何 PHP 脚本并导致禁止在该文件夹中创建任何其他新文件?
本质上,我希望特定的 CHMOD 能够使这成为可能。 非常感谢您的建议。
In a folder say /folderX/
there are 4 .txt files.
A php script currently makes new files if unexistend, based on the site.org/foo/
of the url it updates a new file if foo.txt does not exist, then it will go ahead and create it.
But I would wish to:
A) If the existing file is already in the folder, then allow it to update/rewrite it BUT
B) If the file is non existing e.g. foo.txt, then DONT allow it to create any more new files in folder /folderX/
Reason is that search engines sometimes accidentally check folders like /images/ or /icons/ or /articles/ etc and all those files become then created and PHP goes processing them. If the file cannot be made, then probably PHP will not process them and give them strange crawlers the error they deserve to see.
What properties should I set in the FTP folder folderX, to overule any PHP scripts and cause a disallowance of creation of any further new files in that folder?
Essentially I hop that a particular CHMOD will make this possible.
Thanks very much for your suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果创建了所有文件,则您可以在文件夹上设置权限
555
,以删除其他用户(Web 服务器和 PHP)和目录条目所有者的写入标志。其中的文件将保留 rw- 标志,因此仍然可写。请注意,这仅在没有 PHP 脚本删除任何
fileX.txt
条目的情况下才有效。一旦不喜欢,写入权限就会消失。(顺便说一句,您还可以在文件夹上使用权限
111
,甚至禁止列出该文件夹中的内容。更隐蔽。但可能没有必要。)If all the files are created, then you can set the permisson
555
on the folder to remove the write flag for other users (webserver and PHP) and owner on directory entries. The files within will retain therw-
flag and thus still be writable.Note that this only works if no PHP script deletes any of the
fileX.txt
entries. Once unliked the write permissions are gone.(Btw, you could also use the permission
111
on the folder to even disallow listing of contents within that folder. More sneaky. But there's probably no need.)