【问题标题】:Heroku 403 Forbidden for static js filesHeroku 403 禁止静态 js 文件
【发布时间】:2015-04-25 09:23:07
【问题描述】:

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

@987654321@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654322@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654323@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654324@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654325@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654326@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654327@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654328@ Failed to load resource: the server responded with a status of 403 (Forbidden) @987654329@ Failed to load resource: the server responded with a status of 403 (Forbidden)

可能是什么问题?

【问题讨论】:

  • 有人知道答案吗?我面临同样的问题

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


【解决方案1】:

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

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

【讨论】:

    【解决方案2】:

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

    【讨论】:

    • 感谢您的回答。就我而言,我将 vendor 目录重命名为其他目录,静态文件完美无缺。
    • 我很高兴它有帮助
    【解决方案3】:

    这是由于 .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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-05-24
      • 2022-01-27
      • 2016-04-01
      • 2018-02-20
      • 2016-11-28
      • 2020-05-28
      • 2012-07-17
      • 2016-05-19
      相关资源
      最近更新 更多