'500 Error on Heroku hosted PHP Website, from .htaccess Config file

I'm working on an API with PHP Language, and I'm confused regarding why it works fine offline but not online on Heroku. Within the root directory, there is a ".htaccess" file.

Problem: Offline, it works just fine when tested with the postman, but when tested online, it throws back 500 errors, nothing changed, just the run environment.

Codes:

Options -Indexes

 <Files .htaccess>
    order deny,allow
    deny from all
 </Files>

 AddDefaultCharset UTF-8
 FileETag None
 Options +FollowSymLinks -MultiViews

 RewriteEngine On
 RewriteCond %{SCRIPT_FILENAME} !-d
 RewriteRule ^([^.]+)$ $1.php [NC,L]

 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]

 RewriteCond %{REQUEST_URI} !^/index\.php
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteCond %{REQUEST_FILENAME} !-d
 RewriteRule .* index.php [L]

Purpose of the .htaccess code above is, Option line protects directories, the <Files> line protects my htaccess file, the AddDefaultCharset line cleans URL for user profile, from the RewriteEngine on line, it is intended to remove .php from the file, and also allow multiple parameters on PHP like, index/param1/param2/... which would serve as endpoints.

And it works just fine offline, and online it doesn't except 500 error as seen in the image below.

Screenshot of Postman

After checking the Heroku Log here is what I found.

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source