Fokwa Best February 2016

How can I prevent users from viewing the root directory of my laravel app?

I have a laravel 5 website with the following setup:

http://localhost/my_app/public/auth/login - Users can view site using links like this

but if a user types something such as:

http://localhost/my_app/, he would be able to view the following:

Index of /my_app

[ICO]   Name    Last modified   Size    Description
[PARENTDIR] Parent Directory        -    
[   ]   _ide_helper.php 2015-09-23 08:35    389K     
[DIR]   app/    2016-02-07 22:33    -    
[   ]   artisan 2015-08-30 12:31    1.6K     
[DIR]   bootstrap/  2015-08-30 12:31    -    
[   ]   composer.json   2016-01-03 04:51    1.4K     
[   ]   composer.lock   2016-01-03 04:52    130K     
[DIR]   config/ 2016-02-04 08:28    -    
[DIR]   database/   2015-08-30 12:31    -    
[   ]   gulpfile.js 2015-08-30 12:31    503  
[   ]   package.json    2015-08-30 12:31    159  
[   ]   phpspec.yml 2015-08-30 12:31    87   
[TXT]   phpunit.xml 2015-08-30 12:31    899  
[DIR]   public/ 2015-08-30 12:31    -    
[   ]   readme.md   2015-08-30 12:31    1.9K     
[DIR]   resources/  2015-08-30 12:31    -    
[   ]   server.php  2015-08-30 12:31    567  
[DIR]   storage/    2015-08-30 12:31    -    
[DIR]   tests/  2015-08-30 12:31    -    
[DIR]   vendor/ 2016-01-03 04:53    

How can I block access to this directtory?

Answers


Jilson Thomas February 2016

Set your path directly to the public folder.

For local developement, run the command

php artisan serve

from your command prompt. Now you'll be able to access your app from http://localhost:8000

When you upload it to server , you can just edit

/etc/apache2/sites-available

to point your directory to

/var/www/html/public

Post Status

Asked in February 2016
Viewed 3,783 times
Voted 14
Answered 1 times

Search




Leave an answer