本文介绍了Heroku 403禁止的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我部署了一个PHP应用程序,当我打开url时,出现以下错误:

I deployed a PHP application and when I hit the url, I get the following error:

Forbidden

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

我想它会尝试进入app /目录,但它不能。

I guess it tries to go into the app/ directory but it can't.

我的项目结构:

My project structure:

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






日志显示:


What the log shows:

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






Procfile p>


Procfile

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






.htaccess


.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>


推荐答案

Ehhmm让我找到了解决方案。

Ehhmm so I found the solution.

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

My Procfile had a .txt extension (so Procfile.txt) whereas it needs to be only Procfile.

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

Quit a silly mistake but I thought I should leave the answer here for future reference. Maybe it will save time from someone else.

这篇关于Heroku 403禁止的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-03 20:45