HTTP ERROR 500 on my first slim code

Hello,
I’m new to php and slim too.
I installed on my W10 laptop xampp, vs code and slim(using composer)
I wrote code and tested locally … it works fine.

Then I copy on my shared linux server via filezilla and it doesn’t work (I got http error 500)
I follow then suggestions in documentation and modify files as follow…,

.htaccess

< IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /MYSUBDOMAIN
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
< /IfModule>

index.php

< ?php
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Factory\AppFactory;

require DIR . ‘/vendor/autoload.php’;

$app = AppFactory::create();

$app->setBasePath(’/MYSUBDOMAIN’);

$app->get(’/’, function (Request $request, Response $response, array $args) {

if (!empty($_SERVER['HTTP_CLIENT_IP']))
{
  $ip = $_SERVER['HTTP_CLIENT_IP'];
}
elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR']))
{
  $ip = $_SERVER['HTTP_X_FORWARDED_FOR'];
}
else
{
  $ip = $_SERVER['REMOTE_ADDR'];
}

$yourip= file_get_contents(“http://ipinfo.io/{$ip}/json”);

$response->getBody()->write($yourip);
return $response->withHeader(‘Content-Type’, ‘application/json’);

});

$app->run();
?>

the skeleton of subdomain folders into linux web server is:

\MYDOMAIN
------\MYSUBDOMAIN
-------------\VENDOR (as on my laptop with all subfolder)
------------ .HTACCESS
------------ COMPOSER.JSON
------------ COMPOSER.LOCK
------------ INDEX.PHP

When I enter mysubdomain into chrome url I got error 500 and inside Plesk Log of my server I see 8 Apache errors refering to a non-existent subfolders e.g.:

Error: Unable to find the directory /var/www/vhosts/MYDOMAIN/MYSUBDOMAIN/var/www/vhosts/MYDOMAIN/MYSUBDOMAIN/vendor/slim/slim/Slim: filemng failed: filemng: stat failed: No such file or directory System error 2: No such file or directory

and much more similar to this one.

I suppose I make a mistake somewhere… Anybody can tell me where?
thanks a lot.
Adrian

Usually you don’t need RewriteBase /MYSUBDOMAIN when you configure the correct apache DocumentRoot path.

/var/www/vhosts/MYDOMAIN/MYSUBDOMAIN/var/www/vhosts/MYDOMAIN/MYSUBDOMAIN/vendor/s

This path is not correct. You should point the document root to your public/ directory of the Slim project.

Thank you very much Odan.
I removed RewriteBase and now it works.

Have a nice day.
Adrian