How to deploy slim4 to apache server subfolder?

So I am almost done with my new Slim 4 API and i am trying to move it from xampp to a live server. I am using a shared server and the app will go to a subfolder with the following structure:

public_html/mydomain.com/apps/slim-api/ (this contains all the files).

I tried moving it and creating an .htaccess with this:

RewriteEngine On
RewriteBase /mydomain.com/apps/slim-api
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

But doesnt seem to work (404 error). What am i doing wrong?

This is the complete error i get:

[23-Apr-2020 11:08:41 CST6CDT] 404 Not Found
Type: Slim\Exception\HttpNotFoundException
Code: 404
Message: Not found.
File: /home/tours/public_html/mydomain.com/apps/slim4-api/vendor/slim/slim/Slim/Middleware/RoutingMiddleware.php
Line: 93

Try following the tutorial here: https://akrabat.com/running-slim-4-in-a-subdirectory/

It has helped me deploy my Slim API

1 Like