简体   繁体   English

如何避免在Laravel 4中列出目录

[英]How to avoid directory listing in laravel 4

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. 我是Laravel4的新手,我试图在共享主机上运行laravel4。由于我没有root用户访问权限,所以避免在URL中公开。 I have moved all the contents in the public directory to "public_html" folder. 我已将公共目录中的所有内容移至“ public_html”文件夹。

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. 但是,当我访问URL“ abc.com/myapp/app”时,它列出了app目录下的所有文件夹和文件。 Since it exposes the project files, I was looking to avoid the same. 由于它公开了项目文件,因此我希望避免相同的情况。

In CodeIgniter if we try to access folders like this it gives message 在CodeIgniter中,如果我们尝试访问这样的文件夹,则会显示消息

"Directory access is forbidden." “禁止目录访问。”

Edit: 编辑:

I have added 我已经添加了

Options All FollowSymLinks MultiViews -Indexes 选项全部FollowSymLinks MultiViews-索引

in a .htaccess file in the app folder as per suggested by @valey viktorovsky 根据@valey viktorovsky的建议,在app文件夹中的.htaccess文件中

There are multiple methods... 有多种方法...

The easy one: 简单的一个:
If you have access to .htaccess file and you can modify it, place this little code 如果您有权访问.htaccess文件并且可以对其进行修改,请放置以下代码

Options -Indexes  

Annoying one 烦人的
If you cannot create/modify .htaccess file, create index.html file inside each folder you would like to protect 如果无法创建/修改.htaccess文件,请在要保护的每个文件夹中创建index.html文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM