Summer Sale! All accounts are 50% off this week.

adrianmcg85's avatar

Heroku Laravel 403 Forbidden - tried all possible options but cant show page

Cant display my webpage with Laravel 5.8.16 I have tried changing my .htaccess and Procfile but had no luck. My logs are a follows:

2019-05-26T12:14:28.299263+00:00 heroku[router]: at=info method=GET path="/" host=still-forest-63735.herokuapp.com request_id=34d76826-da87-4880-b8b6-c74a6a764b3e fwd="109.150.176.100" dyno=web.1 connect=0ms service=1ms status=403 bytes=373 protocol=https
2019-05-26T12:14:28.299758+00:00 app[web.1]: [Sun May 26 12:14:28.298889 2019] [autoindex:error] [pid 141:tid 140447896823552] [client 10.16.233.224:13780] AH01276: Cannot serve directory /app/: No matching DirectoryIndex (index.php,index.html,index.htm) found, and server-generated directory index forbidden by Options directive
2019-05-26T12:14:28.300168+00:00 app[web.1]: 10.16.233.224 - - [26/May/2019:12:14:28 +0000] "GET / HTTP/1.1" 403 209 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
PS D:\laravel_testing_project\lar2\laravel> php artisan --version

My .htaccess in public is:

<IfModule mod_rewrite.c>
    <IfModule mod_negotiation.c>
Options +SymLinksIfOwnerMatch.
    </IfModule>

    RewriteEngine On

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

    # Handle Front Controller...
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule "^(.*)$ public/$1" [L]

</IfModule>

My Procfile is:

"web: vendor/bin/heroku-php-apache2 public/" 
0 likes
12 replies
Punksolid's avatar

@ADRIANMCG85 - You need to install the heroku-cli and then set this way the environment variables

 heroku config:set HELLO=WORLD

To check it just run heroku config and you should see the keys values you just set

adrianmcg85's avatar

I have heroku-cli installed and have set hello=world. I also get APP_KEY value

Nash's avatar

Are those quotation marks (") in your Procfile? If so, remove them.

adrianmcg85's avatar

I also added an .htaccess to the root directory. This page isnt working and the logs are

PHP Fatal error:  require(): Failed opening required '/app/public/vendor/autoload.php' (include_path='.:/app/.heroku/php/lib/php') in /app/public/index.php on line 24

Which i believe is the

require __DIR__.'/vendor/autoload.php';

line on my index.php. File is being selected.

Nash's avatar
Nash
Best Answer
Level 20

@ADRIANMCG85 - Did you make changes to index.php? I think the default line should be:

require __DIR__.'/../vendor/autoload.php';
Nash's avatar

Also, that's not what the default Laravel .htaccess file is supposed to look like?

Try using the default file: https://raw.githubusercontent.com/laravel/laravel/master/public/.htaccess

...or the alternative one in the docs: https://laravel.com/docs/5.8/installation#pretty-urls

...and check the Procfile like I said, it should not have quotation marks.

I also added an .htaccess to the root directory. This page isnt working and the logs are...

Why would you need do that? Don't randomly change or add things, otherwise it will be impossible to figure out where the actual problem is. Read the docs for Heroku and Laravel.

Nash's avatar
 ReflectionException
Class App\Http\Controllers\indexController does not exist

Is the controller supposed to have a lowercase "i" in its name or is it actually IndexController? Linux is case-sensitive while Windows is not (in most cases), so you might need to check your file/controller names if you've been developing on Windows.

Kiraos's avatar

in Procfile I remove " it works.

1 like

Please or to participate in this conversation.