繁体   English   中英

Heroku 403 禁止错误

[英]Heroku 403 Forbidden Error

我部署了一个 PHP 应用程序,当我点击 url 时,我收到以下错误:

Forbidden

You don't have permission to access / on this server.

我猜它试图进入 app/ 目录,但它不能。


我的项目结构:

my-project
|
|-> app/
|-> public/ (index.php inside here that takes care of routing)
Procfile
composer.json
etc.

日志显示的内容:

Jul 24 12:44:08 cryptic-beyond-39147 app/web.1:  [Sun Jul 24 19:44:07.846582 2016] [autoindex:error] [pid 99:tid 139960748263168] [client 10.179.164.130:28253] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive 
Jul 24 12:44:08 cryptic-beyond-39147 app/web.1:  10.179.164.130 - - [24/Jul/2016:19:44:07 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.63 Safari/537.36 
Jul 24 12:44:13 cryptic-beyond-39147 heroku/router:  at=info method=GET path="/" host=cryptic-beyond-39147.herokuapp.com request_id=9b5e81de-440b-4001-90a4-bc94ee891d3c fwd="89.210.178.134" dyno=web.1 connect=0ms service=1ms status=403 bytes=373 

档案

web: vendor/bin/heroku-php-apache2 public/

.htaccess

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
        Options -MultiViews
    </IfModule>

    RewriteEngine On

    # Redirect Trailing Slashes If Not A Folder...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^(.*)/$ /$1 [L,R=301]

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^ index.php [L]

    # Handle Authorization Header
    RewriteCond %{HTTP:Authorization} .
    RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

    AddType 'text/css; charset=UTF-8' css

</IfModule>

嗯,所以我找到了解决方案。

我的 Procfile 有一个 .txt 扩展名(所以 Procfile.txt),而它只需要是 Procfile。

退出一个愚蠢的错误,但我认为我应该将答案留在这里以供将来参考。 也许这会节省别人的时间。

我也遇到了同样的问题,因为我在根文件夹中没有任何 index.php 文件,所以我没有得到任何东西,导致该错误。 如果您有同样的问题,那么在 heroku 应用程序 url 之后输入您的主页 php 文件。 例如 - app/custom.php 。

一个真正、简单、小巧的解决方案:

过程文件

姓名。 我将其命名为 ProcFile,这是将ProcFile重命名为Procfile仅首字母大写的问题。

我有同样的问题,通过创建 index.php 文件解决了这个问题。

极其奇怪的错误! Procfile 对我来说不是问题的原因。

出于某种原因,当我在我的根文件夹中创建一个名为“app”的空目录时,它修复了。

我有一个类似的问题:

在我的 index.php 中,我使用的是include_once('index.html')

更改为header('Location: /index.html')并且它可以工作。

注意 index.php 和 index.html 都在根目录下。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM