如何在不将Document Root文件夹公开的情况下保护Laravel。让我们假设我有几个Laravel实例在一个目录中运行。
答案 0 :(得分:0)
我的解决方案是使用htaccess文件来保护所有目录。这是我使用的文件:
RewriteEngine On
RewriteRule ^app - [F]
RewriteRule ^bootstrap - [F]
RewriteRule ^config - [F]
RewriteRule ^database - [F]
RewriteRule ^resources - [F]
RewriteRule ^storage - [F]
RewriteRule ^tests - [F]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !^public /index.php [L,NC]
<FilesMatch "^\.|server\.php|artisan|\.(md|js|json|lock|yml|xml|sh)">
Order allow,deny
Deny from all
</FilesMatch>