Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 4: how to protect assets folder?

I come from CodeIgniter where files/folders are typically protected this way:

.php files

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

index.html files

<html>
<head>
    <title>403 Forbidden</title>
</head>
<body>

<p>Directory access is forbidden.</p>

</body>
</html>

I guess can be possible with .htaccess or hard way but, how can be done using Laravel 4? is there a way using its 'standards'?

Edit: Is a project built for shared hosting.

/assets/{css, img, js}
/packages
/system/{app, bootstrap, vendor, index.php, .htaccess, favicon.ico}
like image 854
quantme Avatar asked Jan 24 '26 01:01

quantme


1 Answers

You need to make a file .htaccess, after that you need to add the following:

# Disable Directory Browsing
Options All -Indexes
like image 171
thuan le van Avatar answered Jan 25 '26 17:01

thuan le van



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!