【发布时间】:2020-01-27 21:33:58
【问题描述】:
我有一个生产中的网站无法访问 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 和directives 内部的样子
网站是使用 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>
【问题讨论】:
-
我在 css 文件夹中找不到指令文件夹。让我们重新检查您的生产目录。
-
我的生产中确实有与本地版本相同的目录
-
因为您使用 url "css/directives/gallery.css" 加载 css 文件,但该文件在您的生产中的 "directives" 文件夹中不存在,因此出现错误 404。
-
来看看Production里面的文件我有gallery.css
-
在您的 HTML 中发布文件“gallery.css”的完整 URL。
标签: php laravel .htaccess public