My .htaccess:
<IfModule mod_rewrite.c>
Options -MultiViews
RewriteEngine On
RewriteBase /silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [QSA,L]
</IfModule>
Index.php:
<?php
ini_set('display_errors', 1);
require_once __DIR__.'../vendor/autoload.php';
$app = new Silex\Application();
$app->get('/hello/{name}', function ($name) use ($app) {
return 'Hello '.$app->escape($name);
});
$app->run();
I got this error when accessing localhost/silex/hello/world:
"Sorry, the page you are looking for could not be found."
why?
Try this in your .htaccess
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /silex/web
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?$1 [QSA,L]
</IfModule>
Location of files should be:
/silex/.htaccess
/silex/web/index.php