拒绝使用htaccess访问目录列表

拒绝使用htaccess访问目录列表

本文介绍了拒绝使用htaccess访问目录列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拒绝访问特定目录以在浏览器中显示其中的文件列表.例如,如果我转到url/localhost/myproject/assets,它将显示其中的所有文件列表,我想否认这一点.另外,如果已登录用户访问特定文件,例如localhost/myproject/assets/uploads/img/1.jpg,则应该可以访问该文件.另外,如果该1.jpg是由其他用户上传的,那么如何拒绝对localhost/myproject/assets/uploads/img/1.jpg的访问.

I want to deny access to particular directory to show list of files in it in the browser. For example, If I go to the url, localhost/myproject/assets, it will show all the list of files in it, I want to deny that. And also if logged in user access specific file in it, for ex : localhost/myproject/assets/uploads/img/1.jpg then it should be accessible.Also how to deny access to a localhost/myproject/assets/uploads/img/1.jpg if that 1.jpg is uploaded by some other user.

我是laravel的新手,非常感谢您的帮助.谢谢

I'm new to laravel ,Any help is much appreciated. thanks

推荐答案

您可以将以下内容添加到文件夹中的.htaccess文件中.这可能会有帮助.

You could add the following to the .htaccess file in the folder. This might help.

Options -Indexes

您不能拒绝其他用户上载的jpg.

You cannot deny the access to the jpg uploaded by another user.

这篇关于拒绝使用htaccess访问目录列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 16:42