Heroku 403 Forbidden for static js files

时间:2015-02-23 21:51:53

标签: javascript heroku http-status-code-403

我已将我的简单php应用程序推送到Heroku并获得某些js文件的403状态。

https://guarded-forest-7267.herokuapp.com/vendor/jquery/dist/jquery.min.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jquery-form/jquery.form.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jquery-validate/dist/jquery.validate.min.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jquery.inputmask/dist/inputmask/jquery.inputmask.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/modernizer/modernizr.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jselector/src/jquery.jselector.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/rubber-carousel/dist/jquery.rubber-carousel.min.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/jmodal/src/jquery.jmodal.js Failed to load resource: the server responded with a status of 403 (Forbidden) https://guarded-forest-7267.herokuapp.com/vendor/scrollReveal.js/dist/scrollReveal.min.js Failed to load resource: the server responded with a status of 403 (Forbidden)

问题是什么?

3 个答案:

答案 0 :(得分:1)

我面临着同样的问题。这是因为您试图访问供应商目录中的文件。由于某些heroku权限问题,无法访问“ vendor”文件夹中的静态文件。

我将文件移动到名为“ js”的新目录,然后重新部署了该应用程序。现在工作正常。

答案 1 :(得分: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

答案 2 :(得分:0)

确保您的静态目录在Heroku中没有保留字,例如vendor和bin。要获取更多信息,请参见devcenter.heroku.com/articles/deploying-php