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