Rooting problem

I don’t know why my slim app is acting strange, all urls are considered as index “/”, Example:

i have those 3 urls :

$app->get(’/’, function ($request, $response){return “index”;});
$app->get(’/user’, function ($request, $response){return “user”;});
$app->get(’/superuser’, function ($request, $response){return “superuser”;});
if i navigate to localhost or localhost/user or localhost/superuser or event any other url localhost/ANYTHING ; I always get index with HTTP STATUS 200

Help Please

Did you set the .htaccess?

Try using this one.

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

You could also post a pastebin link for see your code.

Hello thank you for replying,

Actually it was a problem with my php built-in server i was running this command :
php -S public/index.php
instead of this one :
php -S -t public public/index.php

i would apreciate if you can explain the difference to me :slight_smile:


As of PHP 5.4.0, the CLI SAPI provides a built-in web server.

The web server runs a only one single-threaded process, so PHP applications will stall if a request is blocked.

URI requests are served from the current working directory where PHP was started, unless the -t option is used to specify an explicit document root. If a URI request does not specify a file, then either index.php or index.html in the given directory are returned. If neither file exists, the lookup for index.php and index.html will be continued in the parent directory and so on until one is found or the document root has been reached. If an index.php or index.html is found, it is returned and $_SERVER[‘PATH_INFO’] is set to the trailing part of the URI. Otherwise a 404 response code is returned.

1 Like