Heroku静态js文件403禁止访问。

8
我已将我的简单php应用程序推送到Heroku,并且对于一些js文件,我得到了403状态。 https://guarded-forest-7267.herokuapp.com/vendor/jquery/dist/jquery.min.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/jquery-form/jquery.form.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/jquery-validate/dist/jquery.validate.min.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/jquery.inputmask/dist/inputmask/jquery.inputmask.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/modernizer/modernizr.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/jselector/src/jquery.jselector.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/rubber-carousel/dist/jquery.rubber-carousel.min.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/jmodal/src/jquery.jmodal.js无法加载资源:服务器响应状态为403(禁止) https://guarded-forest-7267.herokuapp.com/vendor/scrollReveal.js/dist/scrollReveal.min.js无法加载资源:服务器响应状态为403(禁止)
什么问题可能出现?

有人知道答案吗?我也遇到了同样的问题。 - LNT
3个回答

2

我曾经遇到过同样的问题。这是因为您正在尝试访问'Vendor'目录中的文件。由于某些Heroku权限问题,无法访问'vendor'文件夹中的静态文件。

我将文件移动到一个名为“js”的新目录中,并重新部署了应用程序。现在可以正常工作了。


1

感谢您的回答。在我的情况下,我将 vendor 目录重命名为其他名称,静态文件可以完美地提供服务。 - Michael Iyke
我很高兴它有所帮助。 - Rami Salim

0

这是由于 .htaccess 文件配置错误导致的

如果您的 .htaccess 文件中有任何 RewriteRule,请在其前面添加这些 RewriteCond

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d

例如,此代码允许您将除静态文件之外的所有请求重定向到index.php。
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_URI} !=/index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* /index.php

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接