4

这是我第一次和 Silex 一起玩。我在 GET 和 POST 中尝试了 '/' 路由,一切正常。现在我正在尝试提出更复杂的请求:

<?php

    require_once __DIR__ . '/../vendor/autoload.php';
    $app = new Silex\Application();
    $app->get(
        '/home',
        function () use ($app) {
            return 'Homepage';
        }
    );
    $app->run();

“/home”路由返回“在此服务器上找不到请求的 URL /home。”。为什么?

这是我的 .htaccess:

Options -MultiViews
RewriteEngine On
RewriteCond %{REQUEST_FIOLNAME} !-f
RewriteRule ^ index.php [L]

“/index.php/home”有效

4

2 回答 2

14

试试index.php/home。如果那行得通,那么您将缺少 .htaccess(在 Apache 上)。

看看这里http://silex.sensiolabs.org/doc/web_servers.html

于 2013-10-28T02:08:38.697 回答
4

这应该做的工作:

$ sudo a2enmod rewrite
$ sudo service apache2 restart
于 2016-07-01T12:19:45.470 回答