问题描述
我的 CakePHP v3.x 应用程序在本地 Vagrant 环境中运行良好,但是当我部署到 Heroku 时,对于位于 /webroot/vendor/...
My CakePHP v3.x app runs fine in my local Vagrant environment, but when I deploy to Heroku, I get 403 errors for all javascript files located in /webroot/vendor/...
该目录外的 CSS 和 javascript 文件可以正常加载.
CSS and javascript files outside that directory load fine.
https://example.com/js/i_load_fine.js
https://example.com/vendor/i_cause_403_error.js
/Procfile
web: vendor/bin/heroku-php-apache2
这个问题 听起来很相似,但我查了一下 .htaccess已经有推荐的 RewriteCond:
This question sounds similar, but I checked and .htaccess already has the recommended RewriteCond:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
</IfModule>
推荐答案
原来我必须在 Procfile 中指定文档根目录作为第二个参数: web: vendor/bin/heroku-php-apache2 webroot/
Turns out that I had to specify the document root as a second parameter in the Procfile: web: vendor/bin/heroku-php-apache2 webroot/
这篇关于Heroku 上供应商目录中 js 文件的 403 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!