1
继documentation之后,Silex允许通过URL传入“slugs”以供在您的代码中使用。Silex slugs导致404页面未找到
在下面的示例:
$app = new Silex\Application();
$app->get('/', function() {
return 'HAI';
});
然而,下面给出一个404未找到:
$app = new Silex\Application();
$app->get('/{slug}', function ($slug) {
return 'HAI' . $slug;
});
我怎样才能解决这个404?
在情况下,它的任何相关性,这是我的Apache虚拟主机:
<VirtualHost 127.0.0.1:80>
DocumentRoot "/var/www/Silex/web"
DirectoryIndex index.php
<Directory "/var/www/Silex/web">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
...和我的目录结构:
/src
|-- bootstrap.php
/tests
/vendor
/web
|-- index.php
很确定你可以从你的虚拟主机配置中删除DirectoryIndex index.php – cheesemacfly
嗨@cheesemacfly,如果你想复制这个答案,并为你自己添加它,当你发现它时,随意,我会奖励你upvote &答案:) – Jimbo
没有必要,你在这里完成了这项工作! :) – cheesemacfly