Ariel LR Ariel LR - 1 year ago 105
PHP Question

Can't match a Slim Framework route when using GET parameters

I have the following route defined, I'm using Slim Framework 2:

$app->map('/mail', function () use ($app) {
$mails = array('Hola como estas?', 'Valar Margulis', 'Hola Ariel, este mensaje se autodestruira') ;
$respuesta = array(
'mails' => $mails
) ;

$respuestaJson = json_encode($respuesta) ;

die($respuestaJson) ;
})->via('GET', 'POST');


When I try the route http://slim/mail it works

But then when I try to pass any GET parameter http://slim/mail?inbox=whatever

I get a 404 error, what am I doing wrong?


This is my htaccess file:

RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?param=$1 [QSA,L]

Answer Source

The problem was

RewriteRule  ^(.*)$ index.php?param=$1 [QSA,L]

That 404 error was apache, not Slim. Simply replace with

RewriteRule ^ index.php [QSA,L]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download