when a request url has a dot in it I am getting a 404 error Not found page that says "The requested resource /error.example was not found on this server." What causes this error and is there a way of fixing it? I am using the Slim framework and run my code with the php built-in server. I will put bellow a sample code that recreates the above error.
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->get('/{name}/oth', function (Request $request, Response $response, array $args) {
$name = $args['name'];
$response->getBody()->write($name);
return $response;
});
$app->run();
.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]
Both index.php and .htaccess are located inside the public folder, and i run my code with php -S localhost:8080 -t public/
When I go to my browser and go type the address http://localhost:8080/name/oth
it shows name correctly but when i type http://localhost:8080/name.ex/oth
it shows the error i mentioned
Not Found
The requested resource /name.ex/oth was not found on this server.
Edit:
Adding the requested information:
-Log for php -S localhost:8080 -t public/
:
PHP 8.1.2 Development Server (http://localhost:8080) started
-Log for the request url http://localhost:8080/name/oth:
[::1]:63906 [200]: GET /name/oth
-Log for the request url http://localhost:8080/name.ex/oth:
[::1]:63917 [404]: GET /name.ex/oth - No such file or directory
If i replace index.php with echo 'here'; die;
it displays "here" correctly in the browser.