参数不起作用的细长路径

时间:2015-05-20 16:03:36

标签: php .htaccess slim

我正在尝试为我设置Slim应用程序我遇到的问题是参数不起作用的路径。

这是我的index.php

require 'Slim/Slim.php';

\Slim\Slim::registerAutoloader();

$app = new \Slim\Slim();


// GET route
$app->get('/', function () {
    print "hello";
});



$app->get('/books/:id', function ($id) {
    print $id;
});

$app->run();

这是.htaccess文件

RewriteEngine On

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

/的请求正常,但如果我通过/books/1,则返回 [404]未找到

1 个答案:

答案 0 :(得分:0)

man你的mod_rewrite没有在apache中启用。为了启用mod_rewrite,请关注this.Reference http://www.kingpabel.com/apache-mod-rewrite/

<Directory /var/www/html>
AllowOverride All
</Directory>

//enable mod rewrite
a2enmod rewrite

//restart apache
service apache2 restart
相关问题