# HTTP ERROR 500 on my first slim code

**URL:** <https://discourse.slimframework.com/t/http-error-500-on-my-first-slim-code/4498>\
**Category:** Questions\
**Created:** [November 11, 2020, 8:19am UTC](https://discourse.slimframework.com/t/http-error-500-on-my-first-slim-code/4498 "2020-11-11T08:19:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![adr](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adr](https://discourse.slimframework.com/u/adr)\
**Post date:** [November 11, 2020, 8:19am UTC](https://discourse.slimframework.com/t/http-error-500-on-my-first-slim-code/4498/1 "2020-11-11T08:19:24Z")

</div>

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](http://ipinfo.io/%7B%24ip%7D/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

---

<div class="post-metadata">

**Author:** ![odan](https://avatars.discourse-cdn.com/v4/letter/o/9de053/32.png) [@odan](https://discourse.slimframework.com/u/odan)\
**Post date:** [November 11, 2020, 4:13pm UTC](https://discourse.slimframework.com/t/http-error-500-on-my-first-slim-code/4498/2 "2020-11-11T16:13:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![adr](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@adr](https://discourse.slimframework.com/u/adr)\
**Post date:** [November 11, 2020, 5:27pm UTC](https://discourse.slimframework.com/t/http-error-500-on-my-first-slim-code/4498/3 "2020-11-11T17:27:40Z")

</div>

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

Have a nice day.  
Adrian
