首页 > 解决方案 > 公共文件夹中的文件不显示 [Laravel]

问题描述

我有一个生产中的网站无法访问 public/css 中的某些文件夹。我检查了所有文件夹的权限,检查了公用文件夹中的 .htaccess ,我找不到某些文件夹出现在我的本地版本中的原因Local,但没有出现在我的生产版本中Prod

例如:

<link rel="stylesheet" href="{{ asset('css/directives/gallery.css') }}"/>

在我的本地版本中,它可以工作,因为显示了文件夹指令,但在生产中我收到 404 错误。

Failed to load resource: the server responded with a status of 404 (Not Found)

这是它在我的生产服务器Production Files和内部指令上的外观

网站是使用 Laravel 5.4 用 PHP 编写的,下面是我在生产中的 .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]

    # 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>

标签: phplaravel.htaccesspublic

解决方案


授予公共文件夹的所有权限 chmod -R 777 public


推荐阅读