I worked on a personal project on my computer, and it works perfectly fine on the localhost of this computer. But I tried to put it online using my Raspberry Pi as a web server and it doesn't work (it shows a 404 error). It's a project using PHP AltoRouter. And I noticed that on my computer, $_SERVER['BASE-URI'] returns the url coming after 'localhost', but on my RaspberryPi, it returns 'NULL'.
In the public folder, my index.php file starts like this:
<?php
require '../vendor/autoload.php';
require '../app/Controllers/MainController.php';
require '../app/Controllers/LevelController.php';
$pageToDisplay = '/';
// thanks to the htaccess redirection, no querystring can be seen in the url. Htaccess will add the information about the requested page
if (isset($_GET['_url'])) {
$pageToDisplay = $_GET['_url'];
}
$router = new AltoRouter();
// we indicate to AltoRouter where the root of the site is with basePath
$router->setBasePath($_SERVER['BASE_URI']);
My Htaccess file is like this:
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule . index.php [L]
Has anyone any idea where this issue could be coming from ? When I set up my Rpi as a web server, I installed Apache2, PHP, MySQL, PHPMyAdmin, Git, VS Code, Composer (and I also wrote the commands 'composer install' and 'composer dump-autoload'). Is there something I forgot to do when I set up my Raspberry Pi ?
Thank you for your time !