如何在laravel子文件夹中设置htaccess?

时间:2017-04-04 05:47:21

标签: laravel .htaccess

我在laravel project的根目录中有一个名为admin的文件夹。该文件夹中有js,css,images和fonts.Now如何拒绝其他人在laravel中访问该文件夹?

1 个答案:

答案 0 :(得分:0)

我用htaccess中的代码解决了这个问题:

<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
    Options -MultiViews
</IfModule>

RewriteEngine On

# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)/$ /$1 [L,R=301]
RewriteRule ^admin(.*)/$ /$1 [L,R=301] //this line is for admin folder access limitation
# Handle Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]

# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]