限制对目录中的文件浏览器访问 [英] Restrict browser access to directory files

查看:164
本文介绍了限制对目录中的文件浏览器访问的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的网站,我要限制观看它们存储在一个名为/内容目录中的某些文件,例如,只有登录的用户可以查看文件

In my website, i want to restrict viewing certain files which are stored in a directory called "/content" such that only logged in users can view the files

,因为它代表现在的人谁类型xxxxxxx.com/content/4dc32b1c0a630.png~~V到浏览器可以看到该图片文件

as it stands right now anyone who types in xxxxxxx.com/content/4dc32b1c0a630.png into the browser can see this image file

我添加选项-Indexes到我的.htaccess文件,但没有做任何事情。

I've added Options -Indexes to my .htaccess file but that didn't do anything

如果这是我的网站正在使用codeigniter建有帮助,所以一个PHP的解决方案将是巨大的,但我会采取任何建议,你可能有!

if it is helpful my site is built using codeigniter, so a PHP solution would be great, though I'd take any advice you might have!

感谢您, 蒂姆·

推荐答案

您可以编写一个控制器,用于这一目的。

You can write a controller for that purpose.

在我的一个项目我做只为登录用户调整大小的图片控制器。它是基于timthumb脚本 HTTP://$c$c.google.com/p/timthumb /

In one of my projects I've done a resized pictures controller only for logged in users. It's based on timthumb script http://code.google.com/p/timthumb/

在控制器__contruct();写用户认证code,这一切!

In controller __contruct(); write user authentification code and that's all!

所以,你将通过控制器,如 http://www.site.com/调用这些文件图片/ 1314.png

So you will call these files via controller, like http://www.site.com/images/1314.png

这篇关于限制对目录中的文件浏览器访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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