如何避免在Laravel 4中列出目录 [英] How to avoid directory listing in laravel 4

查看:63
本文介绍了如何避免在Laravel 4中列出目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Laravel4的新手,我试图在共享主机上运行laravel4.由于我没有root用户访问权限,因此请避免在我的url中使用public.我已经将公共目录中的所有内容都移到了"public_html"文件夹中.

I am new to Laravel4, I was trying to run laravel4 on a shared hosting.Since I dont have root access, to avoid public in my url. I have moved all the contents in the public directory to "public_html" folder.

然后,我更改了相应文件中的位置.但是,当我访问URL"abc.com/myapp/app"时,它列出了app目录下的所有文件夹和文件.由于它公开了项目文件,因此我希望避免相同的情况.

Then I changed the locations in respective files. But when I visited url "abc.com/myapp/app", it lists all the folders and files under app directory. Since it exposes the project files, I was looking to avoid the same.

在CodeIgniter中,如果我们尝试访问这样的文件夹,它将发出消息

In CodeIgniter if we try to access folders like this it gives message

禁止目录访问."

我已添加

选项所有FollowSymLinks多视图-索引

Options All FollowSymLinks MultiViews -Indexes

按照@valey viktorovsky的建议,在app文件夹中的.htaccess文件中

in a .htaccess file in the app folder as per suggested by @valey viktorovsky

推荐答案

有多种方法...

最简单的方法:
如果您有权访问.htaccess文件,并且可以对其进行修改,请放置以下小代码

The easy one:
If you have access to .htaccess file and you can modify it, place this little code

Options -Indexes  

烦人的
如果无法创建/修改.htaccess文件,请在要保护的每个文件夹中创建index.html文件

Annoying one
If you cannot create/modify .htaccess file, create index.html file inside each folder you would like to protect

这篇关于如何避免在Laravel 4中列出目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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