How to avoid directory listing in laravel 4

瘦欲@ 提交于 2019-12-25 04:13:07

问题


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.

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.

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

"Directory access is forbidden."

Edit:

I have added

Options All FollowSymLinks MultiViews -Indexes

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


回答1:


There are multiple methods...

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

Options -Indexes  

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



来源:https://stackoverflow.com/questions/17720947/how-to-avoid-directory-listing-in-laravel-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!