限制对目录中的文件浏览器访问浏览器、文件、目录中

2023-09-02 20:40:46 作者:过来我怀里

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

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!

所以,你将通过控制器,如 https://m.xsw88.com/allimgs/daicuo/20230902/55.png

So you will call these files via controller, like https://m.xsw88.com/allimgs/daicuo/20230902/56.png