在此服务器上找不到请求的URL错误

时间:2017-11-25 11:13:36

标签: php .htaccess twig silex

我正在尝试使用Twig和Silex创建一个网站,但是当我想要访问404 Not Found页时,我收到/test错误。

http://127.0.0.1/public_html/M1-CSI/web/有效。

http://127.0.0.1/public_html/M1-CSI/web/test不起作用。

的.htaccess

<IfModule mod_rewrite.c>
   Options -MultiViews

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

路由文件

<?php

$routes = $app['controllers_factory'];

$routes->get('/', 'Sources\\Controllers\\ExempleController::exemple');
$routes->get('/test', 'Sources\\Controllers\\ExempleController::test');

return $routes;

控制器

<?php

namespace Sources\Controllers;

use \Silex\Application;

class ExempleController {

    public function exemple(Application $app) {
        return $app['twig']->render('exemple.html.twig', array('exempleValue' => 3));
    }

    public function test(Application $app) {
        return $app['twig']->render('test.html.twig');
    }

}

非常感谢。

修改

您可以在此处找到源代码摘录:https://github.com/nlamblin/website-boilerplate

问题解决了。

我添加了以下代码行:

<Directory /var/www/html/>
     Options Indexes FollowSymLinks MultiViews
     AllowOverride All
     Order allow,deny
     allow from all
</Directory>
/etc/apache2/sites-available/000-default.conf

中的

0 个答案:

没有答案
相关问题