【问题标题】:Laravel Deployment on shared hosting gives "Directory index forbidden by Options directive"共享主机上的 Laravel 部署给出“选项指令禁止的目录索引”
【发布时间】:2017-03-09 03:00:54
【问题描述】:

下面是我在 Laravel 主根目录中的 .htaccess/public

.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>
    Options -Indexes
    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # 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}]
</IfModule>

【问题讨论】:

  • 尝试删除Options -Indexes 行。如果有人点击没有索引的文件夹,它负责不显示文件列表。我认为没有必要,拥有就好。

标签: php apache .htaccess laravel laravel-5.2


【解决方案1】:

共享主机的 apache 配置 document root 是 Laravel root。但是 Laravel 在根文件夹中没有 index.php。您可以将 .htaccess 保留在 /public 中,但在根文件夹中您需要将 .htaccess 更改为

<IfModule mod_rewrite.c>
    RewriteEngine On

    RewriteRule ^(.*)$ public/$1 [L]
</IfModule>

【讨论】:

    猜你喜欢
    • 2011-07-15
    • 2018-04-04
    • 2011-10-28
    • 2019-07-16
    • 1970-01-01
    • 2018-03-10
    • 2012-05-09
    • 1970-01-01
    相关资源
    最近更新 更多