Slimについて以下のようにしてTutorial(9:48)を実行した後、スリム機能をテストすると、まだ「ページが見つかりません」というメッセージが表示されます。 programmがeg.Ifは「http://localhost/authentication/public/test/Hello」で検索特定のポイントの後、ページが「こんにちは」エコーすべきである検索バーに入力した任意の単語をエコーすることになっている
、ページが「こんにちは」をエコーする必要があります。
これは、.htaccessファイルを使用してindex.phpへのリンクを再ルーティングすることによって行われます。 index.phpファイルは、start.phpというphpファイルを実行します。
なぜこれが機能しないのでしょうか?
スリムv3.xの
の.htaccess
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule^index.php [QSA,L]
のindex.php
<?php
require '../app/start.php';
$app->run();
?>
start.php
<?php
use Slim\App;
session_cache_limiter(false);
session_start();
ini_set('display_errors', 'On');
define('INC_ROOT', dirname(__DIR__));
require INC_ROOT . '/vendor/autoload.php';
$app = new App();
$app->get('/test/:name', function($name) {
echo "Hello! {$name}";
});
?>
Apache Webサーバーを使用していますか? .htaccessとindex.phpはディレクトリ構造のどこにありますか?どのURLにindex.phpに直接アクセスしていますか?http://localhost/authentication/public/index.phpですか? – jirka