【问题标题】:how to set htaccess in laravel subfolder?如何在 laravel 子文件夹中设置 htaccess?
【发布时间】:2017-04-05 11:29:48
【问题描述】:

我在 laravel 项目的根目录中有一个名为 admin 的文件夹。该文件夹中有 js、css、图像和字体。现在如何拒绝其他人访问 laravel 中的该文件夹?

【问题讨论】:

标签: laravel .htaccess


【解决方案1】:

我在 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}]

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-02-15
    • 1970-01-01
    • 1970-01-01
    • 2014-09-15
    • 2022-10-13
    • 2021-11-26
    • 2013-09-03
    相关资源
    最近更新 更多