Heroku上供应商目录中的js文件出现403错误

eme*_*his 6 javascript .htaccess cakephp heroku

我的CakePHP v3.x应用程序在我的本地Vagrant环境中运行良好,但是当我部署到Heroku时,我收到的所有javascript文件都有403个错误 /webroot/vendor/...

加载该目录之外的CSS和javascript文件.

https://example.com/js/i_load_fine.js
https://example.com/vendor/i_cause_403_error.js
Run Code Online (Sandbox Code Playgroud)

/ Procfile

web: vendor/bin/heroku-php-apache2
Run Code Online (Sandbox Code Playgroud)

这个问题听起来很相似,但我查了一下.htaccess已经有了推荐的RewriteCond:

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)

小智 9

我想知道"供应商"是否是Heroku中的保留字?

是的,如果您将使用"vendor"文件夹名称,可能会出现403错误.因为root dir web服务器vendor/bin/.不要使用公共名称"vendor"和"bin".


eme*_*his 0

结果我必须在 Procfile 中指定文档根作为第二个参数:web: vendor/bin/heroku-php-apache2 webroot/